fix: удалить дублирующиеся реализации и починить импорты

Co-authored-by: aider (deepseek/deepseek-chat) <aider@aider.chat>
This commit is contained in:
Evgeny Bushkov
2026-11-06 00:48:28 +03:00
co-authored by aider
parent bedadbb63e
commit a8571b4f1b
6 changed files with 0 additions and 237 deletions
-29
View File
@@ -1,32 +1,3 @@
"""Хеширование паролей (Argon2id) и генерация opaque-токенов сессий."""
import hashlib
import secrets
from argon2 import PasswordHasher
from argon2.exceptions import VerifyMismatchError, VerificationError, InvalidHashError
_hasher = PasswordHasher()
def hash_password(password: str) -> str:
return _hasher.hash(password)
def verify_password(password_hash: str, password: str) -> bool:
try:
return _hasher.verify(password_hash, password)
except (VerifyMismatchError, VerificationError, InvalidHashError):
return False
def new_token() -> str:
"""256 бит энтропии, URL-safe."""
return secrets.token_urlsafe(32)
def token_hash(token: str) -> str:
"""В БД/Redis храним только SHA-256 от токена, не сам токен."""
return hashlib.sha256(token.encode("utf-8")).hexdigest()
import hashlib
import secrets
from datetime import datetime, timedelta, timezone