Advertisement
Guest User

Untitled

a guest
Jul 13th, 2017
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.10 KB | None | 0 0
  1. """Your challenge for today is to create a program which is password protected, and wont open unless the correct user and password is given.
  2. For extra credit, have the user and password in a seperate .txt file."""
  3.  
  4. import getpass
  5.  
  6.  
  7. def passcheck(user, password):
  8.     passfile = open('0005_easy_credentials.txt', 'r')
  9.     for line in passfile:
  10.         fileuser, filepass = line.split('$')
  11.         print(fileuser, filepass)
  12.         if user != fileuser:
  13.             continue
  14.         if password == filepass:
  15.             return True
  16.     passfile.close()
  17.     return False
  18.  
  19. def passchange(user, password):
  20.     pass
  21.  
  22. def userchange(user, password):
  23.     pass
  24.  
  25. def adduser(user, password):
  26.     pass
  27.  
  28. in_user = input('Username: ')
  29. in_pass = getpass.getpass('Password: ')
  30. if passcheck(in_user, in_pass) is True:
  31.     print('Welcome, %s!' % in_user)
  32.     print('What would you like to do today?')
  33.     action = input('[S]witch user\n[C]reate new user\n[R]eset credentials\n')
  34.     """switch_user
  35.    new_user
  36.    change_name
  37.    change_pass"""
  38. else:
  39.     print(in_user, in_pass)
  40.     print('Access denied.')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement