This commit is contained in:
papapevagemabody
2026-11-06 13:57:17 +03:00
commit a9af58a083
91 changed files with 11253 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
"""Argon2id. Одновременно считаются не более двух хешей."""
from threading import Semaphore
from argon2 import PasswordHasher
from argon2.exceptions import VerificationError
hasher = PasswordHasher(time_cost=2, memory_cost=19456, parallelism=1)
slots = Semaphore(2)
def hash_password(password):
with slots:
return hasher.hash(password)
def matches(encoded, password):
with slots:
try:
return hasher.verify(encoded, password)
except VerificationError:
return False