Skip to content

Instantly share code, notes, and snippets.

@lukhnos
Created February 6, 2015 08:24
Show Gist options
  • Save lukhnos/b08e6fb399f708c69aa5 to your computer and use it in GitHub Desktop.
Save lukhnos/b08e6fb399f708c69aa5 to your computer and use it in GitHub Desktop.
A simple command line pyotp wrapper
import argparse
import json
import pyotp
def main():
parser = argparse.ArgumentParser()
parser.add_argument('json', nargs=1)
parser.add_argument('key', nargs=1)
args = parser.parse_args()
with open(args.json[0]) as f:
j = json.load(f)
seed = j.get(args.key[0])
if seed:
totp = pyotp.TOTP(seed)
print(totp.now())
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment