optimize+注释

This commit is contained in:
stardrophere
2026-03-13 23:48:49 +08:00
parent 6aee65af6c
commit da00ebb8f2
41 changed files with 874 additions and 174 deletions
+7 -1
View File
@@ -60,7 +60,13 @@ def hash_verification_code(code: str) -> str:
def verify_verification_code(code: str, expected_hash: str) -> bool:
return hmac.compare_digest(hash_verification_code(code), expected_hash)
try:
# compare against string to avoid type issues with hmac.compare_digest
code_hash = str(hash_verification_code(code))
expected = str(expected_hash)
return hmac.compare_digest(code_hash, expected)
except Exception:
return False
def _urlsafe_b64encode(raw: bytes) -> str: