jeudi 4 février 2021

How to apply OTP in python

I am fairly new to programming and trying to create a program where a user get OTP by using random library and applies to log in to gain access of a file only if it match otherwise permission denied. Not sure what am I doing wrong here as it goes in infinite loop when I run. Below is my code:

def rand_pass(size):
  

generate_pass=''.join([random.choice(string.ascii_uppercase+string.ascii_lowercase+string.digits)for n in range(size)])    
  return generate_pass 

OTP = rand_pass(10)
print('password:'+OTP)

Password = input('enter your OTP here:')

OTP = input('enter your OTP here:')
new_otp = "OTP"


OTP = new_otp
while OTP != "new_otp":
  print('Welcome')

  if OTP == "new_otp":
   print('welcome')
   break
  else:
    print('ACCESS DENIED.')
    continue

Thanks in advance.




Aucun commentaire:

Enregistrer un commentaire