add password hashing
This commit is contained in:
parent
33469b8840
commit
9ad5cab717
1 changed files with 4 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
|||
import getpass # hides types characters, very useful
|
||||
import json
|
||||
import sys
|
||||
import hashlib # python standard lib for hashing
|
||||
|
||||
def get_credentials():
|
||||
username = input('Enter your username: ')
|
||||
|
@ -11,7 +12,9 @@ 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}: ')
|
||||
# hash the password before saving to the database
|
||||
pwdb[username] = hashlib.sha256(f'{password}'.encode()).hexdigest()
|
||||
return pwdb
|
||||
|
||||
def read_pwdb(pwdb_path):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue