Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions auth.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import json
from random import randint

def get_credentials():
username = input('Enter your username: ')
password = pwhash(input(f'Enter your password {username}: '))

password = input(f'Enter your password {username}: ')
return username, password

def read_passwdb():
Expand All @@ -23,17 +23,20 @@ def pwhash(password):

def add_user(pwdb, username, password):
if username not in pwdb:
pwdb[username] = password

salt = randint(100000,999999)
x = str(salt)+password
hash = pwhash(x)
pwdb[username] = (salt,hash)

def authenticate(username, password, pwdb):
if username in pwdb:
if password == pwdb[username]:
salt, hash = pwdb[username]
if pwhash(str(salt)+password) == hash:
return True
else:
return False
else:
add_user(pwdb, username, password)
add_user(pwdb, username, password) #make sure to add the hash into these arguments
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

has this comment been addressed/can it be removed?

return True

def main():
Expand Down