A quick and simple usage of HOTP
:
import otpauth
totp = otpauth.HOTP(b"user-secret")
# generate a code for now
code: int = totp.generate()
# you may want to convert it to string
str_code: str = totp.string_code(code)
# verify the code
totp.verify(code) # => True
totp.verify(str_code) # => True
Install with pip:
pip install otpauth
- Documentation: https://otp.authlib.org/
- Blog: https://blog.authlib.org/
- Twitter: https://twitter.com/authlib
2013, Hsiaoming Yang. Under BSD-3 license.