bellstrand/totp-generator

Throws "Invalid base32 character in key" for all input keys I tried

toadslop opened this issue · 3 comments

Tried using this package, but unfortunately I would get the error "Invalid base32 character in key" no matter what input key I used. I tried all numbers. I tried all letters. I tried an empty string. Always the same error.

@toadslop You gotta provide some more information.
That error is thrown if you provide an invalid key. A valid key contains A-Z, 2-7 and =.
Can you provide the string that you are trying with? As well as your NodeJS version?
And does the test suite pass for you? yarn test

@bellstrand Thanks for responding. I apologize for the lack of details. I was able to determine the issue -- it was that the strings were, of course, not encoded properly in base32. Basic mistake, I know.

I could suggest some improvements for the package because I'm sure others might be confused as well. One would be to add to the documentation that the string must be encoded in base32. I was originally thrown off by the fact that this wasn't mentioned in the documentation.

It could be further improved if the package simply took any string as an input key and converted it to base32. I think many people would just assume that any input string would work and get confused like it did, so the package could pick up more users if it were able to handle this. There may be a good reason not to, admittedly. I don't know enough about TOTP to be sure.

It could definitely use some documentation! (I'll make sure to write something about it).

TOTP tools such as Google Authenticator always use base32 key's because that provides a human readable string. So can't say I've thought more about it than that.