tet.util.crypt module

Password hashing utilities using passlib.

This module provides functions for securely hashing and verifying passwords using SHA-256 crypt.

Example

Hashing and verifying passwords:

from tet.util.crypt import crypt, verify

# Hash a password
hashed = crypt("my_secret_password")

# Verify a password
if verify("my_secret_password", hashed):
    print("Password is correct!")

Note

For SQLAlchemy models, consider using tet.sqlalchemy.password.UserPasswordMixin which integrates this functionality directly into your model.

tet.util.crypt.crypt(password)[source]

Hash a password using SHA-256 crypt.

Parameters:

password – Plaintext password (str or bytes)

Returns:

Hashed password string

tet.util.crypt.verify(password, hash)[source]

Verify a password against a hash.

Parameters:
  • password – Plaintext password to verify (str or bytes)

  • hash – Hash to verify against

Returns:

True if password matches, False otherwise