fixed visible passwords

This commit is contained in:
ASPP Student 2025-09-22 16:03:20 +03:00
parent 33469b8840
commit 1e9b41120c

View file

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