Implement hashing
This commit is contained in:
parent
b42ef06d91
commit
7ed1ba6cf4
9
auth.py
9
auth.py
|
@ -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')
|
||||
|
|
Loading…
Reference in a new issue