Implement hashing

This commit is contained in:
ASPP Student 2024-08-26 15:02:27 +03:00
parent b42ef06d91
commit 7ed1ba6cf4

View file

@ -10,12 +10,17 @@ def get_credentials():
return (username, password)
def authenticate(username, password, pwdb):
return password == pwdb[username]
return pwhash(password) == pwdb[username]
def add_user(username, pwdb):
pwdb[username] = input(f'Enter password for {username}: ')
password = input(f'Enter password for {username}: ')
pwdb[username] = pwhash(password)
return pwdb
def pwhash(password):
ord_password_num = [int(ord(character)) for character in password]
return sum(ord_password_num)
def read_pwdb(PWDB_PATH):
try:
pwdb_file = open(PWDB_PATH, 'rt')