hash passwords, resolves #6

This commit is contained in:
ASPP Student 2024-08-26 15:29:28 +03:00
parent b42ef06d91
commit 29d70502e0

View file

@ -1,19 +1,20 @@
import json
import sys
from getpass import getpass
import hashlib
PWDB_PATH = 'pwdb.json'
def get_credentials():
username = input('Enter your username: ')
password = getpass('Enter your password: ')
password = hashlib.sha256(getpass('Enter your password: ').encode()).hexdigest()
return (username, password)
def authenticate(username, password, pwdb):
return password == pwdb[username]
def add_user(username, pwdb):
pwdb[username] = input(f'Enter password for {username}: ')
pwdb[username] = hashlib.sha256(input(f'Enter password for {username}: ').encode()).hexdigest()
return pwdb
def read_pwdb(PWDB_PATH):