Реализовать ЛР 7 на оценку 3
This commit is contained in:
+12
-2
@@ -1,7 +1,17 @@
|
||||
from argon2 import PasswordHasher
|
||||
import os
|
||||
|
||||
from argon2 import PasswordHasher, Type
|
||||
from argon2.exceptions import VerificationError, VerifyMismatchError
|
||||
|
||||
_hasher = PasswordHasher()
|
||||
_memory = int(os.getenv('ARGON2_MEMORY_KIB', '19456'))
|
||||
_iterations = int(os.getenv('ARGON2_ITERATIONS', '2'))
|
||||
_parallelism = int(os.getenv('ARGON2_PARALLELISM', '1'))
|
||||
if _memory < 19456 or _iterations < 2 or _parallelism < 1:
|
||||
raise RuntimeError('Argon2id requires at least 19 MiB, t=2 and p=1')
|
||||
|
||||
_hasher = PasswordHasher(
|
||||
memory_cost=_memory, time_cost=_iterations, parallelism=_parallelism, type=Type.ID,
|
||||
)
|
||||
|
||||
|
||||
def hash_password(password: str) -> str:
|
||||
|
||||
Reference in New Issue
Block a user