hash password #8
9
auth.py
9
auth.py
|
@ -9,11 +9,16 @@ def get_credentials():
|
|||
password = getpass('Enter your password: ')
|
||||
return (username, password)
|
||||
|
||||
def get_hash(password):
|
||||
_hash = sum([ord(letter) for letter in password])
|
||||
return _hash
|
||||
|
||||
def authenticate(username, password, pwdb):
|
||||
return password == pwdb[username]
|
||||
|
||||
def add_user(username, pwdb):
|
||||
pwdb[username] = input(f'Enter password for {username}: ')
|
||||
pwd = input(f'Enter password for {username}: ')
|
||||
pwdb[username] = get_hash(pwd)
|
||||
return pwdb
|
||||
|
||||
def read_pwdb(PWDB_PATH):
|
||||
|
@ -41,7 +46,7 @@ if __name__ == "__main__":
|
|||
if username not in pwdb:
|
||||
print('Wrong username!')
|
||||
else:
|
||||
if authenticate(username, password, pwdb):
|
||||
if authenticate(username, get_hash(password), pwdb):
|
||||
print('Successfully authenticated!')
|
||||
else:
|
||||
print('Wrong password!')
|
||||
|
|
Loading…
Reference in a new issue