Bcrypt Hash Generator Online | Password Hash & Verify

Hash Functions
100% client-side. Processed locally in your browser using the Web Crypto API. Nothing is sent to any server.

How It Works

Bcrypt truncates passwords at 72 bytes. Longer passwords are silently truncated before hashing. For passwords exceeding 72 bytes, consider pre-hashing with SHA-256. Use cost factor 12 or higher for new systems — cost 10 is the minimum for login flows.

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

CostIterations (2^cost)Time (~ms)Best for
101,024~60msLogin flows, standard security
124,096~240msRecommended default, balanced
1416,384~960msHigh-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

Using cost factor below 10. Cost 10 is the minimum for login flows. Cost 12 is recommended for new systems. Lower costs make brute-force attacks feasible on modern hardware.
Storing passwords longer than 72 bytes without pre-hashing. Bcrypt silently truncates passwords at 72 bytes. For longer passwords, pre-hash with SHA-256 before applying bcrypt.
Using fast hashes for passwords. Never use SHA-256, SHA-512, or MD5 directly for password storage. These are designed to be fast, making brute-force attacks practical. Always use adaptive hashes like bcrypt, scrypt, or Argon2.
Reusing salts. Bcrypt automatically generates a random salt for each hash. Never manually provide a salt — let bcrypt handle it. Each hash of the same password should produce a different output.
Ignoring the hash format. Bcrypt output format is $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

Bcrypt is slow by design. This makes brute-force attacks computationally expensive. Each increment of the cost factor doubles the hashing time.
Each hash includes a salt. The salt ensures identical passwords produce different hashes, preventing rainbow table attacks. The salt is stored as part of the hash output.
Compatible with Node.js bcrypt. This tool uses bcryptjs, a pure JavaScript implementation fully compatible with the Node.js bcrypt package. Hashes generated here can be verified in your backend.
Consider Argon2 for new systems. While bcrypt is well-established, Argon2 (winner of the Password Hashing Competition) offers better resistance against GPU-based attacks. Use Argon2id if available.

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

Related Concepts

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

Learn More