Bcrypt hashes Go will accept
Set to the $2a$ prefix and cost 10 that Go 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 x/crypto package writes $2a$ and its DefaultCost is 10. It refuses passwords longer than 72 bytes with an error rather than truncating them, which most other libraries do not.
The same thing in Go
Hashing in Go
hash, err := bcrypt.GenerateFromPassword([]byte("correct horse battery staple"), 12)Checking a password
err := bcrypt.CompareHashAndPassword(storedHash, []byte(candidate))
if err == nil {
// the password matched
}From a terminal
go run ./cmd/hash "correct horse battery staple"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.
- Java Hashes for jBCrypt and Spring Security, $2a$ prefix.
- Spring Security Hashes for BCryptPasswordEncoder, $2a$ prefix at strength 10.