duo-cli/duo_gen.py

25 lines
378 B
Python
Raw Permalink Normal View History

2019-03-20 10:41:31 +00:00
#!/usr/bin/env python3
import pyotp
import sys
if len(sys.argv) == 2:
file = sys.argv[1]
else:
file = "duotoken.hotp"
f = open(file, "r+");
secret = f.readline()[0:-1]
offset = f.tell()
count = int(f.readline())
2019-03-20 10:41:31 +00:00
print("secret", secret)
print("count", count)
hotp = pyotp.HOTP(secret)
2019-03-20 10:41:31 +00:00
print("Code:", hotp.at(count))
f.seek(offset)
f.write(str(count + 1))
f.close()