Of all the numbers in a password system, the bcrypt cost factor looks the most like a security score: higher feels safer, so why not turn it up? Teams do exactly that, ship it, and then watch their login page take a full second on every sign-in, forever. The cost was not chosen against a measurement. It was chosen against a feeling.
bcrypt cost is not a score. It is a dial that sets how much work every single password check performs, and each step on that dial doubles the work. This guide explains what that doubling really costs, who pays it, and how to land on the honest target with the free Bcrypt Hash Generator on Ovatly: one check taking roughly 250 ms on your own production server.
Contents
- Quick answer
- Cost is a doubling dial, not a volume knob
- Who pays for a high cost
- The 250 ms target: choosing the number honestly
- Feel the cost in the tool, step by step
- Worked example: cost 10 against cost 12
- Limitations and honest tradeoffs
- Common mistakes
- FAQs
- Conclusion
- References
Quick answer
Set bcrypt cost so that one verification takes roughly 250 ms on your production server, and re-tune it as hardware improves. On current hardware that usually means cost 10 to 13. Every step above that doubles the wait on every login while adding little real protection, because an attacker guesses weak passwords first. You can feel the doubling yourself in the Bcrypt Hash Generator: generate at cost 10, then at 12, and the second run takes about four times as long. The tool warns at 11 and 12, because a browser tab can freeze mid-generation at those costs.
Cost is a doubling dial, not a volume knob
The cost factor is an exponent wearing a friendly disguise. Cost 10 does not mean ten units of work; it means the key setup runs through 2 to the power of 10 rounds. Move to cost 11 and the work doubles. Move to cost 12 and it doubles again: four times the cost 10 workload.
That arithmetic is the whole story of this mistake. A developer who nudges the setting from 10 to 14 has not made login 40 percent slower. They have made it sixteen times slower, and they have done it to the most latency-sensitive request in the application: the one a user is actively waiting on, expecting to be let in.
The dial exists for a good reason. Hardware gets faster every year, and a work factor that doubles per step lets bcrypt keep pace across decades. The dial is meant to be re-set as machines improve. It is not meant to be pinned at the top.
Who pays for a high cost
Every legitimate login pays, every time. Verification repeats the hashing work with the salt and cost stored in the hash, so a cost 14 setting charges full price on each sign-in and password change. Multiply a one-second check by a busy morning of logins and the bill arrives in server capacity as well as patience: fewer concurrent logins per machine, queues at peak, and pressure to add hardware to serve a number nobody measured.
The attacker, meanwhile, pays less than the headline suggests. Offline guessing against a stolen database is dominated by password quality, not cost. Attackers try the most common passwords first, and the accounts that fall are the ones protected by a pet's name or a reused credential. Doubling the delay does not rescue those accounts; the strong passwords were never going to be guessed anyway.
The 250 ms target: choosing the number honestly
Real applications pick a cost by timing, not by taste. The widely used target is roughly 250 ms for one check on the production server: slow enough that mass guessing becomes expensive, fast enough that a human signing in perceives a responsive system. On current hardware, that means cost 10 to 13.
Three consequences follow. First, the measurement only counts on the production machine; a cost tuned on a fast workstation will crawl on a small server. Second, the right number drifts: a cost chosen years ago may now run in 30 ms, quietly cheaper than intended, so re-tuning belongs in routine maintenance. Third, stored hashes carry their own cost inside the string, so old and new settings coexist; users are rehashed at the new cost on their next login.
Feel the cost in the tool, step by step
- Open the Bcrypt Hash Generator and enter any password.
- Generate at the default cost of 10 and note how long the tab spends working.
- Raise the cost to 12 and generate again. The run takes about four times as long, and the tool warns here because the tab can freeze while it works.
- Compare the two strings: only the cost digits, salt and hash differ. The format is identical; the workload is not.
Worked example: cost 10 against cost 12
Suppose one verification on your server at cost 10 takes roughly 250 ms, right on target. The doubling dial predicts the rest of the row:
Cost 10: about 250 ms per check
Cost 11: about 500 ms per check
Cost 12: about 1,000 ms per check
Cost 13: about 2,000 ms per check
Nothing about the passwords changed. A single digit in a settings file decided whether sign-in feels instant or broken, and whether a login server handles four checks a second per core or one check every two seconds. That is the trade a too-high cost makes, silently, at scale.
Limitations and honest tradeoffs
The 250 ms figure is a target, not a law. A high-security system with few logins may accept a slower check; a consumer service with millions of daily sign-ins may tune a little faster and lean on other defences. What is not defensible is choosing the number with no measurement at all.
The browser tool also caps its range at 4 to 12, deliberately below what production tuning sometimes uses, because its job is teaching, not deployment. And cost is only one part of password storage: bcrypt itself truncates input at 72 bytes, and Argon2id, the newer alternative, adds memory hardness that resists GPU-based guessing. A well-tuned bcrypt remains a sound choice; a badly tuned one is a self-inflicted outage in slow motion.
Common mistakes
- Setting the highest cost available "for security". Each extra step doubles every login's wait. Past the 250 ms target, the gains are small and the tax is permanent.
- Tuning on the wrong machine. Cost is only meaningful as a time measured on the production server. A fast laptop will happily approve a number that cripples a small instance.
- Never re-tuning. Hardware improves, so a cost that took 250 ms years ago may now take a fraction of that. A setting that was once right quietly becomes too cheap.
- Believing cost fixes weak passwords. Attackers guess the obvious passwords first. Cost slows the guessing; it does not make a bad password good.
- Switching to a fast hash because bcrypt feels slow. The slowness is the entire point. SHA-256 and its relatives are built for speed, which makes them cheap to guess against and wrong for passwords.
FAQs
What does the bcrypt cost factor actually change? It changes how much work one hash or verification takes. Each step up doubles the work, so cost 12 takes four times as long as cost 10, and that delay applies to every login, not just to attackers.
What cost should I use? Tune it on your own production server so that one check takes roughly 250 ms. For most servers today that lands between cost 10 and 13. Re-tune as hardware improves, because a cost that was right years ago may now be too cheap.
Is a higher cost always safer? No. Past the point where one check takes about 250 ms, extra cost mostly punishes your own users at every sign-in. An attacker guessing passwords goes after weak passwords first, and a doubled or quadrupled delay does not rescue a password like a pet's name.
Why does the Ovatly tool warn at cost 11 and 12? Because the hashing runs in your browser tab, and at those costs a single generation can freeze the tab while it works. The warning makes the doubling cost of each step something you can feel at small scale.
Should I use something other than bcrypt? bcrypt remains a sound choice when it is tuned properly. Argon2id is the newer alternative, adding memory hardness that resists GPU-based guessing. What you should never use is a fast hash like SHA-256, which is built for speed and therefore cheap to guess against.
Conclusion
The bcrypt cost factor rewards measurement and punishes enthusiasm. Pick the number that makes one check take roughly 250 ms on the server serving your logins, note when you chose it, and revisit it as hardware moves. If you want to see the parts of the string that carry the cost, our companion guide on reading a bcrypt hash part by part walks through a real example. For more guides in this series, see our Security and Privacy Utilities guides.
References
- OWASP Cheat Sheet Series, Password Storage Cheat Sheet, on tuning bcrypt work factors against server response time: https://cheatsheetseries.owasp.org/cheatsheets/Password_Storage_Cheat_Sheet.html
- Provos, N. and Mazières, D. (1999), "A Future-Adaptable Password Scheme", Proceedings of the USENIX Annual Technical Conference, the original bcrypt paper.