-
-
Save oofnikj/9d6a81cd591a3b67ef7f18eee55f1f06 to your computer and use it in GitHub Desktop.
TOTP CLI generator
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
#!/usr/bin/env python | |
# put this file in your $PATH to generate TOTP from command line (don't forget to `chmod +x`) | |
import os | |
import sys | |
import pyotp | |
import pyperclip | |
try: | |
TOTP_SECRET_FILE = os.path.expanduser(sys.argv[1]) | |
except IndexError: | |
sys.stderr.write(f"Usage: {sys.argv[0]} /path/to/base32_totp_secret\n") | |
exit(1) | |
totp = pyotp.TOTP(open(TOTP_SECRET_FILE).read()).now() | |
pyperclip.copy(totp) | |
print(totp) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment