Centralize hashing

This commit is contained in:
2025-05-11 11:19:59 +02:00
parent d0b92b220e
commit b34c49d3e3
4 changed files with 17 additions and 17 deletions

View File

@ -93,3 +93,9 @@ def decode_token(settings: AdminServerSettings, token: str) -> TokenData | None:
except jwt.InvalidTokenError as e:
LOG.debug("Could not decode token: %s", e, exc_info=True)
return None
def hash_password(password: str) -> str:
"""Hash password."""
salt = bcrypt.gensalt()
hashed_password = bcrypt.hashpw(password.encode(), salt)
return hashed_password.decode()