TelegramAktienBot/webservice/helper_functions.py

12 lines
363 B
Python
Raw Normal View History

2022-03-14 06:32:16 +00:00
import hashlib
import uuid
def hash_password(password):
salt = uuid.uuid4().hex
return hashlib.sha256(salt.encode() + password.encode()).hexdigest() + ':' + salt
def check_password(hashed_password, user_password):
password, salt = hashed_password.split(':')
return password == hashlib.sha256(salt.encode() + user_password.encode()).hexdigest()