py-bcrypt
raw JSON → 0.4 verified Fri May 01 auth: no python abandoned
A minimal bcrypt password hashing and key derivation library for Python. Current version 0.4 is outdated and no longer maintained; most users should switch to bcrypt or passlib.
pip install py-bcrypt Common errors
error ModuleNotFoundError: No module named 'bcrypt' ↓
cause The library is not installed or import name is wrong.
fix
Install with 'pip install py-bcrypt' and import as 'import bcrypt'.
error TypeError: Unicode-objects must be encoded before hashing ↓
cause Passing a string instead of bytes to bcrypt functions.
fix
Encode the string: bcrypt.hashpw(password.encode('utf-8'), bcrypt.gensalt()).
Warnings
deprecated py-bcrypt is abandoned and not compatible with modern Python (3.x+). Use bcrypt or passlib instead. ↓
fix Replace py-bcrypt with 'bcrypt' (pip install bcrypt) and update imports accordingly.
gotcha py-bcrypt is extremely slow compared to modern alternatives (e.g., bcrypt, argon2). It uses a pure Python implementation. ↓
fix Switch to a C-extension based library like bcrypt.
gotcha The salt generation with gensalt() returns bytes; ensure you pass bytes to hashpw. ↓
fix Always use bytes: bcrypt.hashpw(password.encode(), bcrypt.gensalt()).
Imports
- bcrypt wrong
from pybcrypt import bcryptcorrectimport bcrypt
Quickstart
import bcrypt
password = b"my_password"
hashed = bcrypt.hashpw(password, bcrypt.gensalt())
if bcrypt.checkpw(password, hashed):
print("Password matches")