Bcrypt Hash Generator Online | Password Hash & Verify
Hash Functions How It Works
What Is Bcrypt?
Bcrypt is a password hashing function based on the Blowfish cipher, designed by Niels Provos and David Mazières in 1999. It is specifically designed for password storage — it is intentionally slow, making brute-force attacks computationally expensive. The cost factor (4–20) controls the number of iterations: 2^cost. Each hash includes a random salt and the cost factor, so identical passwords produce different hashes.
When to Use Bcrypt
- Password storage — the gold standard for hashing user passwords before storing them in a database
- Login authentication — verify a user's password against the stored hash without storing the plaintext
- API key hashing — hash API keys before storing them server-side
- Legacy system migration — generate bcrypt hashes to replace weaker hashing schemes (MD5, SHA-1)
- Compliance requirements — many security standards (PCI DSS, OWASP) require adaptive hashing like bcrypt for passwords
Bcrypt Cost Factor Reference
| Cost | Iterations (2^cost) | Time (~ms) | Best for |
|---|---|---|---|
| 10 | 1,024 | ~60ms | Login flows, standard security |
| 12 | 4,096 | ~240ms | Recommended default, balanced |
| 14 | 16,384 | ~960ms | High-security systems |
| 16+ | 65,536+ | ~3.8s+ | Maximum protection, offline hashing |
Standards Compliance
- OpenBSD crypt(3) — original bcrypt implementation by Niels Provos and David Mazières
- RFC 4648 — Base64 encoding used in bcrypt salt/hash format
- bcryptjs — pure JavaScript implementation compatible with Node.js bcrypt
- OWASP — recommended for password storage (along with Argon2 and scrypt)
Last updated:
Code Examples
JavaScript (Browser — bcryptjs)
// Browser — bcrypt hash & verify
import bcrypt from 'bcryptjs';
// Hash password
const password = 'my-secure-password';
const saltRounds = 12;
const hash = await bcrypt.hash(password, saltRounds);
console.log(hash); // $2a$12$...
// Verify password
const isValid = await bcrypt.compare(password, hash);
console.log('Valid:', isValid); // true Python
import bcrypt
# Hash password
password = b'my-secure-password'
salt = bcrypt.gensalt(rounds=12)
hash = = bcrypt.hashpw(password, salt)
print(f'Hash: {hash.decode()}')
# Verify password
is_valid = bcrypt.checkpw(password, hash)
print(f'Valid: {is_valid}') Go
package main
import (
"fmt"
"golang.org/x/crypto/bcrypt"
)
func main() {
password := []byte("my-secure-password")
// Hash password
hash, err := bcrypt.GenerateFromPassword(password, 12)
if err != nil {
panic(err)
}
fmt.Println("Hash:", string(hash))
// Verify password
err = bcrypt.CompareHashAndPassword(hash, password)
fmt.Println("Valid:", err == nil)
} Rust
use bcrypt::{hash, verify, DEFAULT_COST};
fn main() {
let password = "my-secure-password";
// Hash password
let hashed = hash(password, DEFAULT_COST).unwrap();
println!("Hash: {}", hashed);
// Verify password
let is_valid = verify(password, &hashed).unwrap();
println!("Valid: {}", is_valid);
} Node.js
const bcrypt = require('bcrypt');
// Hash password
const password = '12'my-secure-password';
const saltRounds = 12;
const hash = await bcrypt.hash(password, saltRounds);
console.log('Hash:', hash);
// Verify password
const isValid = await bcrypt.compare(password, hash);
console.log('Valid:', isValid); Common Pitfalls
$2a$XX$<22-char salt><31-char hash>. The $2a$ prefix identifies the version. Some systems use $2b$ or $2y$ — all are compatible.
Security Notes
Disclaimer
This tool is provided for educational and development purposes. Bcrypt is a well-established password hashing function, but always follow OWASP guidelines and consult a security professional for production deployments. All computation occurs entirely in your browser.
Further Reading
- Original Bcrypt Paper — Niels Provos and David Mazières (1999)
- OWASP Password Storage Cheat Sheet
- bcryptjs — Pure JavaScript bcrypt Implementation
- Wikipedia — Bcrypt
Related Concepts
- Password Strength Checker — Test Your Passwords
- Password Generator — Create Secure Passwords
- KDF Hash Generator — Key Derivation Functions
- Bcrypt Hash Generator
Related Tools
Need to check password strength before hashing? Try the Password Strength Checker. For generating secure passwords, see the Password Generator. You can also derive keys from passwords using the KDF Hash Generator.
Frequently Asked Questions
What does the cost factor do?
The cost factor (4-20) controls how many iterations the algorithm performs: 2^cost iterations. Higher cost means slower hashing, which makes brute-force attacks more difficult. Cost 10-12 is recommended for most applications, cost 14+ for high-security systems.
Why is the output always $2a$...?
The $2a$ prefix identifies the bcrypt version. The format is $2a$XX$<22-char salt><31-char hash>, where XX is the cost factor. The salt ensures identical passwords produce different hashes. Some systems use $2b$ or $2y$ — all are compatible.
Is this compatible with Node.js bcrypt?
Yes. This tool uses the bcryptjs library, which is a pure JavaScript implementation of bcrypt that is fully compatible with the Node.js bcrypt package. Hashes generated here can be verified in your backend and vice versa.
What is the maximum password length?
Bcrypt truncates passwords at 72 bytes. Longer passwords are silently truncated before hashing. This is a fundamental limitation of the bcrypt algorithm, not a tool restriction.
How do I verify a bcrypt hash?
Scroll to the "Verify Hash" section, enter the password and the hash you want to check, then click "Verify Password". The tool will recompute the hash using the same salt and cost factor, then compare them using constant-time comparison to prevent timing attacks.
Privacy: This tool runs entirely in your browser — nothing is uploaded or stored. · Disclaimer: For educational purposes only. Not professional security advice.
More in Hash
SHA Hash Generator
Generate SHA-256 or SHA-512 hashes from text or files online. Real-time computation, batch upload with CSV export, Hex/Base64 output.
Hash Compare
Compute and compare SHA-1, SHA-256, SHA-384, and SHA-512 hashes side by side online. Hex/Base64 output for checksum verification.
HMAC Generator
Generate HMAC (Hash-based Message Authentication Code) online with SHA-256/384/512. UTF-8/Hex/Base64 input and output, real-time computation.
Merkle Tree Generator
Build Merkle trees and generate proofs online. SHA-256, SHA-512, Keccak-256. Bitcoin duplicate & promote odd-leaf, OpenZeppelin sorted pairs.