Bcrypt hashes Python will accept
Set to the $2b$ prefix and cost 12 that Python expects. Change either one if your project has been configured differently. Nothing you type here leaves the browser.
Everything here runs locally
PHP counts only $2y$ as bcrypt, so Laravel Hash::check() rejects this hash with "This password does not use the Bcrypt algorithm" before it compares anything. Pick $2y$ for PHP, Laravel or Symfony. Why the prefix matters
The bcrypt package writes $2b$ and takes bytes rather than a string, so encode first. Its gensalt default is 12 rounds as of version 4. From version 5.0 onward hashpw raises a ValueError on a password longer than 72 bytes; earlier versions truncated it silently.
The same thing in Python
Hashing in Python
import bcrypt
hash = bcrypt.hashpw(b'correct horse battery staple', bcrypt.gensalt(12))Checking a password
if bcrypt.checkpw(password.encode(), stored_hash):
... # the password matchedFrom a terminal
python -c "import bcrypt; print(bcrypt.hashpw(b'correct horse battery staple', bcrypt.gensalt(12)).decode())"Check a hash from your database
Paste a stored hash and a candidate password to confirm they match, which is a quick way to rule the hash out when a login is failing for reasons you cannot see.
Verification also runs locally
Other stacks
- Laravel Bcrypt hashes with the $2y$ prefix and Laravel defaults.
- PHP Hashes that PHP password_verify accepts, with the $2y$ prefix.
- Node.js Hashes for the bcrypt and bcryptjs packages, $2b$ prefix.
- Java Hashes for jBCrypt and Spring Security, $2a$ prefix.
- Spring Security Hashes for BCryptPasswordEncoder, $2a$ prefix at strength 10.
- Go Hashes for golang.org/x/crypto/bcrypt, $2a$ prefix.