Initial commit: Modernes Harry Potter Escape Quiz Portal (FastAPI & MariaDB)

This commit is contained in:
kobold-ai
2026-09-21 11:29:18 +02:00
commit c3a21369ef
50 changed files with 3346 additions and 0 deletions
Executable
+16
View File
@@ -0,0 +1,16 @@
import os
import hashlib
import secrets
def hash_password(password: str) -> str:
salt = secrets.token_hex(16)
key = hashlib.pbkdf2_hmac("sha256", password.encode("utf-8"), salt.encode("utf-8"), 100000)
return f"{salt}${key.hex()}"
def verify_password(stored_password_hash: str, provided_password: str) -> bool:
try:
salt, key_hex = stored_password_hash.split("$", 1)
new_key = hashlib.pbkdf2_hmac("sha256", provided_password.encode("utf-8"), salt.encode("utf-8"), 100000)
return secrets.compare_digest(new_key.hex(), key_hex)
except Exception:
return False