marcelkliemannel / kotlin-onetimepassword

A Kotlin one-time password library to generate "Google Authenticator", "Time-based One-time Password" (TOTP) and "HMAC-based One-time Password" (HOTP) codes based on RFC 4226 and 6238.
Apache License 2.0
154 stars 25 forks source link

Remove Rogue `/` #25

Closed yashasip closed 6 months ago

yashasip commented 6 months ago

Rogue / Appears at the End of the label

There is a / that is appended at the end of the label. As a result, in the authenticator apps, label ends with /.

For the URI generated using this below:

import dev.turingcomplete.kotlinonetimepassword.OtpAuthUriBuilder
import org.apache.commons.codec.binary.Base32

fun main() {
    val authURI = OtpAuthUriBuilder.forTotp(Base32().encode("secret".toByteArray()))
        .label("John", "Company")
        .issuer("Company")
        .digits(8)
        .buildToString()

    println(authURI)
}

Generated URI: otpauth://totp/Company:John/?issuer Company&digits=8&secret=ONSWG4TFOQ

After scanning the QR code generated using the above URI the key entry as seen on the authenticator app (Google Authenticator): Screenshot from 2024-04-13 23-07-11

This PR fixes this bug.

marcelkliemannel commented 6 months ago

Thanks for the fix!