from flask_sqlalchemy import SQLAlchemy from flask_login import LoginManager from flask_wtf.csrf import CSRFProtect from werkzeug.security import generate_password_hash, check_password_hash # Database and extension initialization db = SQLAlchemy() login_manager = LoginManager() login_manager.login_view = 'auth.login' login_manager.login_message_category = 'info' csrf = CSRFProtect() def hash_password(password): """ Hash a plain text password using werkzeug's security functions. Args: password (str): The plain text password to hash. Returns: str: The hashed password string. """ return generate_password_hash(password) def check_password(password_hash, password): """ Verify a password against its hash. Args: password_hash (str): The stored password hash. password (str): The plain text password to verify. Returns: bool: True if the password matches the hash, False otherwise. """ return check_password_hash(password_hash, password)