def test_totp(): auth = OtpAuth('python') code = auth.totp() assert auth.valid_totp(code) # false assert auth.valid_hotp(1234567) is False assert auth.valid_hotp(123456) is False
def test_hotp(): auth = OtpAuth('python') code = auth.hotp(4) assert auth.valid_hotp(code) == 4 # false assert auth.valid_hotp(1234567) is False assert auth.valid_hotp(123456) is False assert auth.valid_hotp('123456') is False
def test_hotp(): print "\n1.a test hotp" auth = OtpAuth('python') code = auth.hotp() assert auth.valid_hotp(code) print "secret <%s> code <%s>" % (auth.secret, code) #print dir(auth) print "completed successfully"
def qrCoderValid(inputStr): auth = OtpAuth(inputStr) hotp_code = auth.hotp(6) valid = auth.valid_hotp(hotp_code) # hotp_code = auth.hotp(6) # valid = auth.valid_hotp(hotp_code) totp_code = auth.totp(period=30, ) print(totp_code) if auth.valid_totp(totp_code): return totp_code return totp_code
import sys import math from otpauth import OtpAuth count=5 val="kaow" auth = OtpAuth(val) res= auth.hotp(count) print(auth) 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))) print ("Begin of Python Script\n") print ("The passed arguments are ", sys.argv) print ("Show all argument") for i in range(len(sys.argv)): print ("sys.argv["+str(i)+"] => "+str(sys.argv[i]))