Last active
October 9, 2023 14:08
-
-
Save savaged/8c08b4b4ba2ffa82c00a2bf2bfb11b35 to your computer and use it in GitHub Desktop.
Fun with a very basic implementation of TOTP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# generate shared secret for TOTP | |
secret='never gonna give you up' | |
# take only the last 16 characters less padding | |
# apply standard formatting (see https://github.com/google/google-authenticator/wiki/Key-Uri-Format ) | |
# generate the QR code (remember to apply percent encoding for the url) | |
echo -n $secret | base32 | sed 's/=//g' | tail -c 16 | xargs -I $ echo 'otpauth://totp/savaged%20info:[email protected]?secret=$&issuer=Savaged' | xargs qrencode -o ~/Downloads/savaged-qr-code.png | |
#finally, generate TOTP | |
#`echo -n $secret | base32 | sed 's/=//g' | tail -c 16 | xargs oathtool -b --totp` | |
zbarimg -q savaged-qr-code.png | sed -n -e 's/^.*secret=//p' | sed -E 's/^(.*)\&issuer\=\w+/\1/g' | xargs oathtool -b --totp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment