4 ms·
You can also roll your own with https://github.com/pyauth/pyotp https://github.com/pyauth/pyotp
by jcims 5y ago
You can also roll your own with https://github.com/pyauth/pyotp https://github.com/pyauth/pyotp
- codetrotter 5y ago> roll your own Libraries for a couple of other languages: https://crates.io/search?q=4226 https://crates.io/search?q=4226 https://pkg.go.dev/search?q=4226 https://pkg.go.dev/search?q=4226
- tyingq 5y agoIt's almost overkill to bother with a library. #!/usr/bin/env python3 import time, hmac, base64, struct def totp(seed,curtime,period,len): k = base64.b32decode(seed) mac = hmac.new(k, struct.pack('>Q', int(curtime/period)), 'sha1').digest() offset=mac[-1] & 0x0f otp=struct.unpack('>L', mac[offset:offset+4])[0] & 0x7fffffff return str(otp)[-len:].zfill(len) myseed='KRUGS4ZANFZSAYJAOJQW4ZDPNUQHG5DS' # use gpg or similar to store print(totp(myseed,time.time(),60,6))
- jjnoakes 5y agoTrue, I also type this in from memory whenever I need a quick TOTP calculation.