Skip to content

Instantly share code, notes, and snippets.

@perpetual-hydrofoil
Created October 23, 2016 15:47
Show Gist options
  • Save perpetual-hydrofoil/b4c1794ea2f8bf68f861fc6f3567f55d to your computer and use it in GitHub Desktop.
Save perpetual-hydrofoil/b4c1794ea2f8bf68f861fc6f3567f55d to your computer and use it in GitHub Desktop.
TOTP Generator Example (howto)
#! /usr/bin/python
# sudo pip install otpauth first
import time
from otpauth import OtpAuth
__doc__ = """
This can be useful as an example of how to
build your own CLI google auth app.
Use your QR code reader to extract the secret
and then save it somewhere safe (obviously)
This will display an updated TOTP every two seconds:
"""
secret = raw_input('Please provide secret: ').strip()
auth = OtpAuth(secret)
while True:
print '%s' % auth.totp()
time.sleep(.2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment