Created
January 31, 2017 13:30
-
-
Save tsmolka/cb023503d419e7366ada9de52149f10e to your computer and use it in GitHub Desktop.
Derive current OTP-auth tokens from secret (e.g. as in Google Authenticator)
This file contains hidden or 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
| """ | |
| Prerequisites (install using easy_install or pip): | |
| otpauth argparse | |
| Sample token: https://www.google.com/chart?chs=200x200&chld=M|0&cht=qr&chl=otpauth://totp/user@host%3Fsecret%3DAAAAAAAAAAAAAAAA | |
| Usage: python otp.py --secret AAAAAAAAAAAAAAAA | |
| """ | |
| import argparse, time | |
| from otpauth import generate_totp | |
| from base64 import b32decode | |
| if __name__ == '__main__': | |
| parser = argparse.ArgumentParser(description='OTP (e.g. Google Authenticator)') | |
| parser.add_argument('-s', '--secret', required=True) | |
| args = parser.parse_args() | |
| print generate_totp(b32decode(args.secret)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment