Crypt密码加密
Crypt密码加密
from passlib.context import CryptContext
crypt_context = CryptContext(schemes=['bcrypt'], deprecated='auto')
def get_password_hash(password: str) -> str:
"""
生成哈希密码
:param password:
:return: hash_password
"""
hash_password = crypt_context.hash(password)
return hash_password
def verify_password(password: str, hash_password: str) -> bool:
"""
验证密码和哈希密码
:param password: 原密码
:param hash_password: hash密码
:return:
"""
return crypt_context.verify(password, hash_password)
原文:https://blog.csdn.net/qq_33801641/article/details/120644602