ЛР 7: безопасность, mTLS и OpenBao на оценку 3
Skeleton contracts / contracts (pull_request) Blocked by required conditions
Skeleton contracts / contracts (pull_request) Blocked by required conditions
This commit is contained in:
@@ -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()
|
||||
Reference in New Issue
Block a user