You can use a Python library. On my Fedora system I did:
sudo dnf search bcrypt
(the sudo is just to avoid wasting space for a user dnf cache) and from the result can see there is a Python2 and Python3 package:
py-bcrypt.x86_64 : Python bindings for OpenBSD's Blowfish password hashing code
python3-py-bcrypt.x86_64 : Python 3 bindings for OpenBSD's Blowfish password hashing code
Install the Python2 version and list the files in the package:
sudo dnf install py-bcrypt.x86_64
rpm -ql py-bcrypt.x86_64
This shows there is a file /usr/lib64/python2.7/site-packages/bcrypt/__init__.py
so I can get the documentation with
pydoc bcrypt
This shows me enough to write the following command which will hash the string "password"
:
$ python -c 'import bcrypt; print(bcrypt.hashpw("password", bcrypt.gensalt(log_rounds=10)))'
$2a$10$vWFRZgbOx6RKOKYxCTtyWuMJM60E90Vdm/.0nj.X/o3dYUxvQ/2Dm
For later versions of bcrypt
use rounds=
instead of log_rounds=
.