from passlib.context import CryptContext # 创建密码加密上下文 pwd_context = CryptContext(schemes=["pbkdf2_sha256"], deprecated="auto") def verify_password(plain_password: str, hashed_password: str) -> bool: """验证密码""" return pwd_context.verify(plain_password, hashed_password) def get_password_hash(password: str) -> str: """获取密码哈希值""" return pwd_context.hash(password)