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