susam / mintotp

Minimal TOTP generator in 20 lines of Python
MIT License
1.31k stars 88 forks source link

spaces in key raise Non-base32 digit found #7

Closed bytescreator closed 2 years ago

bytescreator commented 4 years ago

it's not a real issue but users can call functions with separated keys.

$ echo "ZYTY YE5F OAGW 5ML7 LRWU L4WT ZLNJ AMZS" | python3 mintotp.py Traceback (most recent call last): File "mintotp.py", line 30, in main() File "mintotp.py", line 26, in main print(totp(key.strip(), args)) File "mintotp.py", line 20, in totp return hotp(key, int(time.time() / time_step), digits, digest) File "mintotp.py", line 11, in hotp key = base64.b32decode(key.upper() + '=' ((8 - len(key)) % 8)) File "/usr/lib/python3.6/base64.py", line 231, in b32decode raise binascii.Error('Non-base32 digit found') from None binascii.Error: Non-base32 digit found $ echo "ZYTYYE5FOAGW5ML7LRWUL4WTZLNJAMZS" | python3 mintotp.py 246648

you were right at the first two issues i was using python2.7 sorry for that. Spaces in the keys broke the script it's not a real issue but i think it's worth to know

key = base64.b32decode(key.upper().replace(" ","") + '=' * ((8 - len(key) + key.count(" ")) % 8))

susam commented 2 years ago

There is no plan to support spaces in the key.