fix password hashing #12

Open
malgorzatawi wants to merge 1 commit from malgorzatawi/2025-plovdiv-git:fixme into live_coding
Showing only changes of commit 7e9acb1be4 - Show all commits

View file

@ -1,17 +1,21 @@
import getpass # hides types characters, very useful
import json
import sys
import hashlib
def get_credentials():
username = input('Enter your username: ')
password = getpass.getpass('Enter your password: ')
password = hashlib.md5(password.encode()).hexdigest()
return (username, password)
def authenticate(username, password, pwdb):
return password == pwdb[username]
def add_user(username, pwdb):
pwdb[username] = getpass.getpass(f'Enter password for {username}: ')
password = getpass.getpass(f'Enter password for {username}: ')
password = hashlib.md5(password.encode()).hexdigest()
pwdb[username] = password
return pwdb
def read_pwdb(pwdb_path):