a9d1b0e416
上轮 3 次 commit 只入库了修补文件,主体目录漏入库。本次补入 backend/app/、backend/requirements.txt、backend/scripts/__init__.py。同步在 .gitignore 加 homePC/(制片人家用机带过来的参考文件,不进库)。
17 lines
428 B
Python
17 lines
428 B
Python
"""
|
|
认证安全工具 — passlib + bcrypt
|
|
"""
|
|
|
|
from passlib.context import CryptContext
|
|
|
|
pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
|
|
|
|
|
|
def hash_password(plain: str) -> str:
|
|
"""用 bcrypt 生成密码哈希。"""
|
|
return pwd_context.hash(plain)
|
|
|
|
|
|
def verify_password(plain: str, hashed: str) -> bool:
|
|
"""验证明文密码与哈希是否匹配。"""
|
|
return pwd_context.verify(plain, hashed) |