Bcrypt hashes Java will accept
Set to the $2a$ prefix and cost 12 that Java 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
jBCrypt writes the $2a$ prefix and defaults to 10 rounds when you call gensalt with no argument. It is unmaintained, so most projects use the Spring Security encoder or a maintained fork.
The same thing in Java
Hashing in Java
String hash = BCrypt.hashpw("correct horse battery staple", BCrypt.gensalt(12));Checking a password
if (BCrypt.checkpw(candidate, storedHash)) {
// the password matched
}From a terminal
jshell --class-path jbcrypt.jar
jshell> BCrypt.hashpw("correct horse battery staple", BCrypt.gensalt(12))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.
- Python Hashes for the Python bcrypt package and passlib, $2b$ prefix.
- Spring Security Hashes for BCryptPasswordEncoder, $2a$ prefix at strength 10.
- Go Hashes for golang.org/x/crypto/bcrypt, $2a$ prefix.