daegalus / dart-otp

RFC6238 Time-Based One-Time Password / Google Authenticator Library
MIT License
100 stars 25 forks source link

Invalid Base32 characters #44

Closed chickahoona closed 1 year ago

chickahoona commented 1 year ago

First thank you very much for the library. I seem to be running into an issue with your TOTP generator which I hope you can help. (Looking at the change log you seem to be fighting here alot with Base32).

So basically I have this TOTP:

otpauth://totp/test?secret=kzvvz2s2ylhdmxzk&algorithm=SHA1&digits=6&period=30

image

Yet when I do a:

OTP.generateTOTPCodeString(
            "kzvvz2s2ylhdmxzk",
            1678614973232,
            algorithm: Algorithm.SHA1,
            interval: 30,
            length: 6,
            isGoogle: true,
          )

I get a "FormatException: Invalid Base32 characters". If I set "isGoogle=false" I get a result, but an incorrect one. At least not the same as Google Authenticator. I am using the otp version 3.1.3, so the latest available one.

Google Authenticator, same as https://totp.danhersam.com/ (which uses https://www.npmjs.com/package/otpauth) accept the QR code without issues.