From fb28c648390464c75ba4903b0e1e0ff2642c8ffb Mon Sep 17 00:00:00 2001 From: Tom van der Lee Date: Thu, 2 Jul 2026 18:34:39 +0200 Subject: Added users and migrations --- authentication/utils.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 authentication/utils.py (limited to 'authentication/utils.py') diff --git a/authentication/utils.py b/authentication/utils.py new file mode 100644 index 0000000..f383969 --- /dev/null +++ b/authentication/utils.py @@ -0,0 +1,15 @@ +import base64 +import hashlib +import bcrypt + + +def bcrypt_sha256_hash(password: str) -> str: + digest = hashlib.sha256(password.encode("utf-8")).digest() + encoded = base64.b64encode(digest) + return bcrypt.hashpw(encoded, bcrypt.gensalt()).decode("utf-8") + + +def bcrypt_sha256_verify(password: str, hashed: str) -> bool: + digest = hashlib.sha256(password.encode("utf-8")).digest() + encoded = base64.b64encode(digest) + return bcrypt.checkpw(encoded, hashed.encode('utf-8')) -- cgit v1.2.3