fix trab 2 / finalizado

This commit is contained in:
2023-09-12 18:09:54 -03:00
parent 428122f04e
commit 8ce9fbd1f0
2 changed files with 5 additions and 7 deletions
+3 -3
View File
@@ -8,9 +8,9 @@ def register_user():
user = input('Digite o usuário: ')
seed_password = sha256(input('Digite a senha: ').encode('utf-8')).hexdigest()
salt = ''.join(random.choice(string.ascii_letters) for i in range(16))
salt = sha256(salt.encode('utf-8')).hexdigest()
hashed_salt = sha256(salt.encode('utf-8')).hexdigest()
line = f'{user},{seed_password},{salt}\n'
line = f'{user},{seed_password},{hashed_salt}\n'
with open('server.dat', 'a', newline='') as setup:
setup.write(line)
@@ -49,7 +49,7 @@ def validate_token():
valid, index = localtoken.validate_token(password, token)
if valid:
if used_index <= index and used_timestamp == localtoken.get_timestamp():
if index >= used_index and used_timestamp == localtoken.get_timestamp():
print('Chave inválida (invalidada)!')
else:
print('Chave válida!')