Use sha256 to encode passwords instead of plain text
This commit is contained in:
parent
33469b8840
commit
e149ba7724
1 changed files with 4 additions and 2 deletions
|
@ -1,17 +1,19 @@
|
|||
import getpass # hides types characters, very useful
|
||||
import json
|
||||
import sys
|
||||
import hashlib
|
||||
|
||||
def get_credentials():
|
||||
username = input('Enter your username: ')
|
||||
password = getpass.getpass('Enter your password: ')
|
||||
password = str(hashlib.sha256(getpass.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] = getpass.getpass(f'Enter password for {username}: ')
|
||||
password = getpass.getpass(f'Enter password for {username}: ')
|
||||
pwdb[username] = str(hashlib.sha256(password.encode()).hexdigest())
|
||||
return pwdb
|
||||
|
||||
def read_pwdb(pwdb_path):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue