implemented password hashing #13

Open
mariiako wants to merge 1 commit from mariiako/2025-plovdiv-git:hashing_feature into live_coding
Showing only changes of commit dbd38303d5 - Show all commits

View file

@ -2,16 +2,23 @@ import getpass # hides types characters, very useful
import json
import sys
def naive_hashing_function(password):
sum=0
password = str(password)
for x in [ord(c) for c in password]:
sum+=x**2
return sum
def get_credentials():
username = input('Enter your username: ')
password = getpass.getpass('Enter your password: ')
return (username, password)
def authenticate(username, password, pwdb):
return password == pwdb[username]
return naive_hashing_function(password) == pwdb[username]
def add_user(username, pwdb):
pwdb[username] = getpass.getpass(f'Enter password for {username}: ')
pwdb[username] = naive_hashing_function(getpass.getpass(f'Enter password for {username}: '))
return pwdb
def read_pwdb(pwdb_path):