solution
Skeleton contracts / contracts (pull_request) Canceled after 0s

This commit is contained in:
2026-11-27 16:42:18 +03:00
parent 20afc2c790
commit a884c07867
133 changed files with 27001 additions and 120 deletions
+51
View File
@@ -0,0 +1,51 @@
"""Измерение Argon2id на стенде и проверка rehash-совместимости."""
from __future__ import annotations
import json
import statistics
import time
from argon2 import PasswordHasher
from messenger.security import _hasher, configure_argon2, password_needs_rehash
def main() -> int:
configure_argon2(19456, 2, 1)
password = "Benchmark-password-32-characters"
hash_times = []
verify_times = []
stored = ""
for _ in range(5):
started = time.perf_counter()
stored = _hasher.hash(password)
hash_times.append((time.perf_counter() - started) * 1000)
started = time.perf_counter()
assert _hasher.verify(stored, password)
verify_times.append((time.perf_counter() - started) * 1000)
old = PasswordHasher(time_cost=1, memory_cost=8192, parallelism=1)
old_hash = old.hash(password)
result = {
"algorithm": stored.split("$")[1],
"version": stored.split("$")[2],
"parameters": stored.split("$")[3],
"hash_ms": {
"runs": len(hash_times),
"median": round(statistics.median(hash_times), 2),
"min": round(min(hash_times), 2),
"max": round(max(hash_times), 2),
},
"verify_ms": {
"median": round(statistics.median(verify_times), 2),
"min": round(min(verify_times), 2),
"max": round(max(verify_times), 2),
},
"old_hash_needs_rehash": bool(password_needs_rehash(old_hash)),
"owasp_minimum_memory_kib": 19456,
}
print(json.dumps(result, indent=2, sort_keys=True))
return 0
if __name__ == "__main__":
raise SystemExit(main())