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__":