fixed visible passwords
This commit is contained in:
parent
33469b8840
commit
1e9b41120c
1 changed files with 9 additions and 2 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue