install
pip install bcrypt
Examples of use
# -*- coding: utf-8 -*-
import bcrypt
passwd = '123456'
# The encryption process
salt = bcrypt.gensalt(rounds=10)
hashed = bcrypt.hashpw(passwd.encode(), salt)
print(salt)
# b'$2b$12$BlfmESsgNnsQFCmpUnhDWO'
print(hashed)
# b'$2b$12$BlfmESsgNnsQFCmpUnhDWO2RbacoHJViT8AZR1qh3DDOHnZxB.J5q'
# Verification process
ret = bcrypt.checkpw(passwd.encode(), hashed)
print(ret) # True