ЛР 7: безопасность, mTLS и OpenBao на оценку 3

This commit is contained in:
2026-12-06 15:19:24 +03:00
parent 20afc2c790
commit 280c5a3300
101 changed files with 5950 additions and 63 deletions
+23
View File
@@ -0,0 +1,23 @@
"""Measure Argon2id hashing and verification inside the constrained app image."""
from statistics import median, quantiles
from time import perf_counter
from app.security import pwd_context
def main():
password = "Synthetic Argon2 measurement sample"
digest = pwd_context.hash(password)
for name, operation in (("hash", lambda: pwd_context.hash(password)),
("verify", lambda: pwd_context.verify(digest, password))):
samples = []
for _ in range(40):
start = perf_counter()
operation()
samples.append(1000 * (perf_counter() - start))
print(f"{name}: n={len(samples)}, p50={median(samples):.2f} ms, "
f"p95={quantiles(samples, n=20)[18]:.2f} ms")
if __name__ == "__main__":
main()