From bfe49e40ed2fbbc1c2d9977542674e011b606d85 Mon Sep 17 00:00:00 2001 From: Florian Date: Thu, 29 Oct 2026 11:24:38 +0100 Subject: [PATCH] Proper exception handling --- src/validator.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/validator.py b/src/validator.py index 6dfca96..8d43bda 100644 --- a/src/validator.py +++ b/src/validator.py @@ -1,4 +1,5 @@ from argon2 import PasswordHasher +from argon2.exceptions import InvalidHashError, VerifyMismatchError ph = PasswordHasher() @@ -8,7 +9,7 @@ def hash_api_key(api_key: str) -> str: def verify_api_key(api_key: str, hashed: str) -> bool: try: return ph.verify(hashed, api_key) - except Exception: + except (VerifyMismatchError, InvalidHashError): return False if __name__=="__main__":