Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """Your challenge for today is to create a program which is password protected, and wont open unless the correct user and password is given.
- For extra credit, have the user and password in a seperate .txt file."""
- import getpass
- def passcheck(user, password):
- passfile = open('0005_easy_credentials.txt', 'r')
- for line in passfile:
- fileuser, filepass = line.split('$')
- print(fileuser, filepass)
- if user != fileuser:
- continue
- if password == filepass:
- return True
- passfile.close()
- return False
- def passchange(user, password):
- pass
- def userchange(user, password):
- pass
- def adduser(user, password):
- pass
- in_user = input('Username: ')
- in_pass = getpass.getpass('Password: ')
- if passcheck(in_user, in_pass) is True:
- print('Welcome, %s!' % in_user)
- print('What would you like to do today?')
- action = input('[S]witch user\n[C]reate new user\n[R]eset credentials\n')
- """switch_user
- new_user
- change_name
- change_pass"""
- else:
- print(in_user, in_pass)
- print('Access denied.')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement