— Type a password to hash automatically —About Bcrypt Hash
Hashing a password once is nowhere near enough for storage. General-purpose hashes such as SHA-256 are designed to be fast and cheap, which is precisely a defect here: once an attacker has the hash database, a graphics card tries billions of candidates per second and the whole set falls in a short time. Password hashing algorithms aim at the opposite, deliberately making each attempt expensive so exhaustive search becomes unaffordable. Two mechanisms carry the design. Salting generates an independent random value per user, mixed into the password so identical passwords produce different hashes and precomputed rainbow tables become useless. A work factor repeats the computation many times, and the count can be raised as hardware improves, so a cost chosen today can be maintained years later by adjusting parameters. Combined, they force an attacker with the hash database to pay dearly for every individual user. Practical notes: Every user needs a distinct salt and never one fixed global value, or an attacker reuses a single computation across the whole set. Set the work factor to roughly one hundred milliseconds per verification on current hardware; too low fails to slow enumeration, too high delays the login endpoint and even turns it into a denial-of-service amplifier. On algorithm choice, bcrypt has the widest compatibility while scrypt and Argon2 resist GPUs and dedicated hardware better, so new systems should prefer the latter. Limits: Bcrypt has a well-known input limit and truncates anything beyond 72 bytes, so the 73rd byte of a long passphrase has no effect; pre-hash long inputs or choose an algorithm without that constraint. The salt and parameters must be stored alongside the hash or verification is impossible. When upgrading the algorithm or raising the work factor, the standard approach is rehashing on the next successful login, known as progressive rehashing, rather than forcing everyone to change passwords at once. And since each verification costs hundreds of milliseconds, the login endpoint needs rate limiting, or an attacker burns server CPU with junk requests. Data and privacy: this tool is for experimenting with parameters and checking them, so never paste real user passwords or production hashes into any online service. For demonstrations use obviously fictional values. In real systems hashing belongs on the server, and hashing a password in the browser does not replace transport encryption. Several supporting controls are not optional. The login endpoint must be rate limited, counted separately per account and per source address, and delay or temporarily lock after a threshold, or even an expensive hash falls to sustained requests. Responses and latency must not distinguish "no such account" from "wrong password", which leaks account existence. Hashes and salts must be backed up with the user record, since losing them is unrecoverable. When migrating algorithms, keep both verification paths and rehash with the new parameters on the next successful login, completing the upgrade without downtime or forcing a password change. Putting these controls into the go-live checklist prevents the most common security gap, where the algorithm is chosen correctly but the surrounding controls are missing.
How It Works Internally
These algorithms deliberately make each computation expensive. A salt, unique per user, is mixed into the password so identical passwords produce different hashes and precomputed tables become useless; a work factor repeats the computation so the cost can be raised as hardware improves. Together they force an attacker with the database to pay dearly per user. Note that input beyond 72 bytes is truncated.
password hunter2, work factor 12$2b$12$K3Jd… and $2b$12$Qp7x… (same prefix and rounds, different salt and digest; both verify)Measured on This Page
| Cross-implementation | The page hash is accepted by Python bcrypt.checkpw; format $2b$10$… at 60 characters |
|---|---|
| 72-byte ceiling | Two passwords identical for 72 bytes but differing at byte 73: the truncated copy of the second verifies against the first one's hash — the tail is discarded |
| Multibyte input | 25 Chinese characters equal 75 bytes and get cut mid-character at byte 72 |
| Added here | An inline warning now appears when the input exceeds 72 bytes; previously this was only mentioned in the page's example prose |
| Cost factor | Entering 20 clamps to 14 ($2b$14$) and 3 clamps to 4 ($2b$04$); the hash prefix reflects the real cost |
| Verify flow | Correct password matches, wrong password does not (covered by the page's Playwright suite) |
The 72-byte limit is part of bcrypt itself, not a bug in this page: every conforming implementation uses only the first 72 bytes, so the second half of a long passphrase contributes nothing. Two remedies: hash once with SHA-256 and feed that to bcrypt, or switch to argon2. Also remember each cost increment doubles the runtime — 14 rounds is around a second here, which a login endpoint cannot afford.
How to Use
- Open "Bcrypt Hash"
- Enter a password and set the cost factor; the hash appears automatically
- Use the copy button on the hash row to take the 60-character value
- Paste the hash and password below, then click "Valid" to verify
- Watch for the 72-byte truncation warning on long passwords
Use Cases
- Seed test account hashes — When manually inserting a user row in a local database, generate a Bcrypt hash in your app's format.
- Verify login logic — Match a plaintext against a stored hash to confirm your backend compare logic is correct.
- Tune the cost factor — Try different cost values on the target server to balance verification time against security.
- Troubleshoot migrations — Check that legacy hashes still verify correctly under new code after a system migration.
- Audit storage format — Inspect the version prefix (2a/2b) and salt in existing hash strings for correctness.
- Test data seeding — Generate pre-hashed passwords for test database seeds so login tests work without a hashing dependency.
- Cost factor benchmarking — Benchmark different cost factors (10-14) on your target hardware to find the ideal balance of security and response time.
FAQ
Why does the same password produce a different hash each time?
Bcrypt uses a fresh random salt every time, and the salt is encoded into the hash string itself. On verification the algorithm reads the salt back out and recomputes, so a different hash still matches correctly.
What cost factor should I use?
Each +1 to cost doubles the work. Common values are 10-12; tune it on production hardware so a single hash takes about 100-300 ms, blocking brute force without hurting login UX.
Does Bcrypt have a length limit?
Yes. Bcrypt only processes the first 72 bytes of input and ignores the rest. To support very long passwords, a common trick is to pre-hash with SHA-256 before passing to Bcrypt.
Can Bcrypt and SHA-256 be swapped?
Not for storing passwords. SHA-256 is extremely fast, which actually helps attackers crack; Bcrypt is intentionally slow and salted, the right choice for password storage. SHA-256 fits integrity checks instead.
What do the 2a, 2b, 2y prefixes mean?
They are Bcrypt version identifiers that diverged due to historical implementation bugs. Modern libraries default to 2b, the most standard; older prefixes usually still verify fine if the library supports them.
Verification reports an invalid salt or simply fails. Where do I start?
Usually the stored hash string was truncated. A complete string carries four parts, namely algorithm identifier, work factor, salt and digest, and must be stored whole; if the database column is too short, a common case being exactly sixty characters when the value is longer, the write is silently cut and verification fails afterwards. First confirm the stored length matches the generated value byte for byte, and only then suspect the algorithm or parameters.
Why does verification take so much longer on a different machine at the same work factor?
The work factor sets the number of rounds while the hardware sets the actual cost, and a newer CPU is often several times faster, just as stricter implementations run slower. The security goal is not a fixed round count but roughly one hundred milliseconds per verification, so the factor should be raised as hardware improves; existing hashes remain verifiable and can be recomputed progressively each time a user logs in.
What cost factor (rounds) should I use for bcrypt?
The default 10 costs tens of milliseconds on modern hardware, right for most login flows; each +1 doubles the time. 10–12 is the common range for logins — higher turns registration into seconds and invites DoS. Changing cost invalidates old hashes, so migrate gradually.