A simple library. Despite its name, it does TOTP and HOTP. To do a TOTP:
import totp, base64
secret = base64.b32decode("ABCDEFGHIJKLMNOP")
code = totp.totp(secret)
if code==input("Insert TOTP here:").strip(): print("Success")
else: print("Failure!")
# alternatively, you can give the secret as a base32 string and the
# library will decode it for you.
secret = "ABCDEFGHIJKLMNOP"
code = totp.totp(secret)
if code==input("Insert TOTP here:").strip(): print("Success")
else: print("Failure!")To do HOTP:
import totp, base64
secret = base64.b32decode("ABCDEFGHIJKLMNOP")
counter = 0
code = totp.hotp(secret,counter)
if code==input("Insert HOTP here:").strip(): print("Success")
else: print("Failure!")
# alternatively, you can give the secret as a base32 string and the
# library will decode it for you.
secret = "ABCDEFGHIJKLMNOP"
counter = 0
code = totp.hotp(secret,counter)
if code==input("Insert HOTP here:").strip(): print("Success")
else: print("Failure!")
Nice and simple library.
I do have one question tho: Is this library safe to use in production? Like can I use this to do 2FA safely?