安装
pip install bcrypt
使用示例
# -*- coding: utf-8 -*- import bcrypt passwd = '123456' # 加密过程 salt = bcrypt.gensalt(rounds=10) hashed = bcrypt.hashpw(passwd.encode(), salt) print(salt) # b'$2b$12$BlfmESsgNnsQFCmpUnhDWO' print(hashed) # b'$2b$12$BlfmESsgNnsQFCmpUnhDWO2RbacoHJViT8AZR1qh3DDOHnZxB.J5q' # 校验过程 ret = bcrypt.checkpw(passwd.encode(), hashed) print(ret) # True