diff options
| author | 2026-07-02 18:34:39 +0200 | |
|---|---|---|
| committer | 2026-07-02 18:34:51 +0200 | |
| commit | fb28c648390464c75ba4903b0e1e0ff2642c8ffb (patch) | |
| tree | 86fa057d26cb07842903aeade09f0fc1bb9614c7 /authentication | |
| parent | 4105c3b777e82cb4b6dadf27c109dd21010ad8ce (diff) | |
| download | server-fb28c648390464c75ba4903b0e1e0ff2642c8ffb.tar.gz server-fb28c648390464c75ba4903b0e1e0ff2642c8ffb.tar.bz2 server-fb28c648390464c75ba4903b0e1e0ff2642c8ffb.zip | |
Added users and migrations
Diffstat (limited to 'authentication')
| -rw-r--r-- | authentication/__init__.py | 0 | ||||
| -rw-r--r-- | authentication/utils.py | 15 |
2 files changed, 15 insertions, 0 deletions
diff --git a/authentication/__init__.py b/authentication/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/authentication/__init__.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 @@ | |||
| 1 | import base64 | ||
| 2 | import hashlib | ||
| 3 | import bcrypt | ||
| 4 | |||
| 5 | |||
| 6 | def 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 | |||
| 12 | def 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')) | ||
