summaryrefslogtreecommitdiffstats
path: root/authentication/utils.py
diff options
context:
space:
mode:
authorGravatar Tom van der Lee <tom@vanderlee.io>2026-07-02 18:34:39 +0200
committerGravatar Tom van der Lee <tom@vanderlee.io>2026-07-02 18:34:51 +0200
commitfb28c648390464c75ba4903b0e1e0ff2642c8ffb (patch)
tree86fa057d26cb07842903aeade09f0fc1bb9614c7 /authentication/utils.py
parent4105c3b777e82cb4b6dadf27c109dd21010ad8ce (diff)
downloadserver-fb28c648390464c75ba4903b0e1e0ff2642c8ffb.tar.gz
server-fb28c648390464c75ba4903b0e1e0ff2642c8ffb.tar.bz2
server-fb28c648390464c75ba4903b0e1e0ff2642c8ffb.zip
Added users and migrations
Diffstat (limited to 'authentication/utils.py')
-rw-r--r--authentication/utils.py15
1 files changed, 15 insertions, 0 deletions
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 @@
1import base64
2import hashlib
3import bcrypt
4
5
6def bcrypt_sha256_hash(password: str) -> str:
7 digest = hashlib.sha256(password.encode("utf-8")).digest()
8 encoded = base64.b64encode(digest)
9 return bcrypt.hashpw(encoded, bcrypt.gensalt()).decode("utf-8")
10
11
12def bcrypt_sha256_verify(password: str, hashed: str) -> bool:
13 digest = hashlib.sha256(password.encode("utf-8")).digest()
14 encoded = base64.b64encode(digest)
15 return bcrypt.checkpw(encoded, hashed.encode('utf-8'))