Files
backend-api-internal/src/validator.py
T
florian 873e7e7854 Improved RabbitMQ handling
- Switched to async because it offers easy automatic reconnect features on connection failure
- Adjusted notification path to reflect that change
- Added in memory message queue if RMQ is not reachable
2025-10-12 21:49:54 +02:00

21 lines
559 B
Python

from argon2 import PasswordHasher
ph = PasswordHasher()
def hash_api_key(api_key: str) -> str:
return ph.hash(api_key)
def verify_api_key(api_key: str, hashed: str) -> bool:
try:
return ph.verify(hashed, api_key)
except Exception:
return False
if __name__=="__main__":
plain_key = "password"
hashed_key = hash_api_key(plain_key)
#hashed_key = '$argon2id$v=19$m=65536,t=3,p=4$vqU+MRafVW1b8AtF+zHb0w$p1J4Gyb0jhlVtKgYyjTITxfU97YaayeS3s3qFFP5sVM'
print("Hashed API Key:", hashed_key)
print("Verification:", verify_api_key(plain_key, hashed_key))