Files
amq-adapter-python/core/security.py
T
2025-02-25 20:37:33 +00:00

20 lines
603 B
Python

from passlib.context import CryptContext
CRIPTO = CryptContext(schemes=['bcrypt'], deprecated='auto') # Automatically workaround deprecated APIs
def validate_pass(password: str, hash_pass: str) -> bool:
"""
Verifies if a given password matches the expected hash.
It compares the user provided text password with the stored hash of the expected password, that
is currently stored in the system.
"""
return CRIPTO.verify(password, hash_pass)
def create_password_hash(password: str) -> str:
"""
Return the hash of the password
"""
return CRIPTO.hash(password)