Dharmang

Validate Password

Dec 17th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.90 KB | None | 0 0
  1. #not running
  2. #this program has been updated and is split into 3 parts, pm if u want the code unless your a pro at python and not like me dummy ;D
  3.  
  4.  
  5. import linecache
  6.  
  7. def user():
  8.     with open('user.txt', 'a') as f:
  9.         usr = input('Enter your username :')
  10.         pwd = input('Enter your password :')
  11.         f.write('Username - ' +usr+ '\nPassword - ' +pwd)
  12.    
  13. def validate():
  14.     with open('user.txt', 'r') as f:
  15.         line = linecache.getline('user.txt',2)
  16.         check = line.split('-')[1].strip()
  17.         temp = input('Enter your Password :')
  18.    
  19.         if check == temp:
  20.             print('Acces Granted!')
  21.         else :
  22.             print('Access Denied!!!!')
  23.    
  24. choice = int(input('Press 1 to Enter a user in the Database\nPress 2 to validate the user\nEnter your Choice :'))
  25. if choice == 1:
  26.     user()
  27. elif choice == 2:
  28.     validate()
  29. else :
  30.     print('WRONG CHOICE!')
Add Comment
Please, Sign In to add comment