hash passwords, resolves #6 #15
5
auth.py
5
auth.py
|
@ -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):
|
||||
|
|
Loading…
Reference in a new issue