Practical Guide

Bcrypt — Usage Guide and Technical Principles

Generate secure password hashes using bcrypt algorithm

Open tool

Overview

Bcrypt is a password hashing function designed by Niels Provos and David Mazières, based on the Blowfish cipher algorithm. It provides adaptive security through configurable work factors, incorporates automatic salt generation to prevent rainbow table attacks, and uses computationally expensive processes that make brute force attacks impractical. Bcrypt is widely considered the gold standard for password hashing in modern applications.

Key concepts

What is Bcrypt Password Hashing

Bcrypt is a password hashing function designed by Niels Provos and David Mazières, based on the Blowfish cipher algorithm. It's specifically designed for password storage and provides adaptive security through configurable work factors. Bcrypt incorporates automatic salt generation to prevent rainbow table attacks and uses a computationally expensive process that makes brute force attacks impractical. It's widely considered the gold standard for password hashing in modern applications.

Adaptive Cost Factor and Security

Bcrypt's adaptive cost factor allows developers to adjust computational complexity based on hardware capabilities and security requirements. The work factor (rounds) can be increased over time as hardware becomes faster, maintaining security against brute force attacks. Typical values range from 10-12 rounds for production environments, with higher values (14-16) for high-security applications.

Salt Generation and Hash Process

Bcrypt automatically generates a unique random salt for each password, preventing rainbow table attacks and ensuring that identical passwords produce different hashes. The process combines the password with the salt, then applies multiple rounds of the Blowfish encryption algorithm. The resulting hash includes the salt and cost factor, making it self-contained and verifiable. This design ensures that even if the hash database is compromised, individual passwords remain protected.

Security Properties and Best Practices

Bcrypt provides essential security properties including resistance to rainbow table attacks, brute force resistance through computational cost, and protection against timing attacks. Best practices include using appropriate work factors (10-12 rounds minimum), never using bcrypt for non-password data, and implementing proper password validation. The algorithm is designed to be slow and memory-intensive,

Features

Secure Hashing: Uses bcrypt algorithm with adaptive cost factors

Uses bcrypt algorithm with adaptive cost factors for secure password hashing

Dual Mode: Support for both password hashing and verification

Support for both password hashing and verification modes

Configurable Rounds: Adjustable cost factor from 4 to 31

Adjustable cost factor from 4 to 31 rounds

Salt Generation: Automatic salt generation for each hash

Automatic salt generation for each hash operation

Use Cases

Security learning and inspection

Use Bcrypt to understand encoded, encrypted, hashed, or security-related data in a controlled browser workflow.

Troubleshooting integrations

Bcrypt helps compare inputs and outputs while debugging tokens, sample payloads, legacy formats, or compatibility behavior.

Safe examples for documentation

Create non-sensitive examples with Bcrypt for internal notes, security reviews, onboarding material, and implementation guides.

FAQ

What is Bcrypt and why should I use it?

Bcrypt is a password hashing function specifically designed for secure password storage. Unlike general hash functions like MD5 or SHA-1, bcrypt is intentionally slow and computationally expensive, making brute force attacks impractical. It automatically generates a random salt for each password and allows you to increase the cost factor over time to maintain security as hardware improves.

What does the number of rounds mean?

The rounds (or cost factor) determines how many iterations the hashing process runs. Each increment doubles the computation time. 10 rounds takes ~100ms, while 12 rounds takes ~400ms. For production environments, 10-12 rounds is recommended, while high-security systems might use 14-16 rounds. Avoid using less than 8 rounds.

Why does the same password generate different hashes each time?

Bcrypt automatically generates a random salt for each hash. This is a core security feature - even identical passwords will produce different hashes due to different salts. This prevents rainbow table attacks and ensures attackers cannot use precomputed lists of hashes. The salt is included in the hash itself, so it can be extracted during verification.

Can bcrypt hashes be reversed?

No, bcrypt is a one-way hash function. There is no mathematical way to recover the original password from the hash. This is what makes it secure for password storage. To verify a password, you hash the same password again (using the stored salt) and compare the result to the stored hash. If the hashes match, the password is correct.

Is bcrypt safe to use in production?

Yes, bcrypt is an industry standard for production use. It's used by all major programming languages including Node.js (bcrypt.js), Python (bcrypt), PHP (password_hash), and Java (jBCrypt). It's recommended by OWASP, NIST, and security experts for password storage. Just ensure you use an appropriate number of rounds (10-12), store hashes securely, and transmit passwords over HTTPS.

Related documentation

Bcrypt

Open the tool to try these features.

Open tool