add password hashing for security #15

Open
juliapa wants to merge 1 commit from juliapa/2025-plovdiv-git:pass_hash into live_coding
Showing only changes of commit 2deecd7e67 - Show all commits

View file

@ -1,17 +1,20 @@
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: ')
text_pass = getpass.getpass('Enter your password: ')
password = hashlib.sha224(text_pass.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}: ')
text_pass = getpass.getpass(f'Enter password for {username}: ')
pwdb[username] = hashlib.sha224(text_pass.encode()).hexdigest()
return pwdb
def read_pwdb(pwdb_path):