APR1OTP are increasing being used in password systems, where a unique code is created every single time there is a login. This code uses both a HOTP (Hashed OTP) and TOTP (Timed OTP) |
Sample
A sample run shows for "secret" and a count of 4 we get a value of "330810":
Hashed OTP is: 330810 Authenication is: 4
For the timed value, the count is used for the time that the hash is valid for. If you select a value of 4, you will get a new hashed password every four seconds:
Time based OTP: 877323 Valid TOTP: True
Code
from otpauth import OtpAuth import sys count=4 val="secret" auth = OtpAuth(val) res= auth.hotp(count) print (("Hashed OTP is: "+str(res))) print ("Authenication is: ",str(auth.valid_hotp(res))) res=auth.totp() print ("Time based OTP: ",str(res)) print ("Valid TOTP: ",str(auth.valid_totp(res)))