implement token generation endpoint

This commit is contained in:
Michi 2025-03-30 18:15:51 +02:00
parent 7f24ba04da
commit b1d7363e81
6 changed files with 64 additions and 8 deletions

11
webservice/crypto.py Normal file
View file

@ -0,0 +1,11 @@
# crypto.py
import hashlib
import secrets
def hash_password(password: str) -> str:
"""Generiert einen SHA-256 Hash des gegebenen Passworts."""
return hashlib.sha256(password.encode()).hexdigest()
def generate_new_token(length: int = 32) -> str:
"""Generiert einen neuen sicheren Token."""
return secrets.token_hex(length) # Erzeugt einen sicheren Token