Ask ten developers what bcrypt cost they use and most will say 10, because 10 is what they have always used. Few can tell you what the number actually does. That matters, because the cost factor is the whole security dial of bcrypt: it decides how expensive every password guess is.

The short version is that cost is a doubling dial. Each step up doubles the work bcrypt performs. This guide explains what that means in practice, who pays the price on each side of a login, and how to pick a number with the free bcrypt Hash Generator on Ovatly as the test bench.

Contents

  • Quick answer
  • What the number actually counts
  • The doubling arithmetic, step by step
  • Who pays: once per login, or once per guess
  • How to pick a cost, step by step
  • Worked example: a timing ladder and a million guesses
  • Limitations and honest tradeoffs
  • Common mistakes
  • FAQs
  • Conclusion
  • References

Quick answer

The bcrypt cost factor sets how much internal work bcrypt does before it answers. Each step up doubles the work, so cost 11 takes twice as long as cost 10, and cost 12 takes four times as long. The defender pays that time once per login; an attacker pays it on every guess. Real applications choose a cost that makes one check take roughly 250 ms on the production server, which commonly means a cost between 10 and 13. In the bcrypt Hash Generator, cost 10 is the classic default, the range runs from 4 to 12, and the tool warns at 11 and 12 because higher costs can freeze a browser tab.

What the number actually counts

The cost is not a percentage, a length or a quality grade. It is an exponent in disguise: bcrypt repeats its internal work a number of times that grows as a power of two as the cost rises. You do not need the exact count to use it well. What matters is the behaviour: raise the cost by one and everything takes twice as long, for you and for anyone guessing.

The cost is also stored inside the hash itself, as the two digits after the version marker. That is why hashes made at different costs can live side by side in one database and each still verify correctly: the checker reads the cost out of the stored string.

The doubling arithmetic, step by step

Doubling sounds gentle until you stack it. One step doubles the work. Two steps double it twice, which is four times the work. Three steps make eight times. The gap between a modest cost and a heavy one is therefore much larger than the small difference in the numbers suggests.

This is the most common misunderstanding about bcrypt cost: people read 10 and 12 as neighbours, roughly twenty percent apart. In time, they are four times apart. A check that feels instant at cost 10 can take a full second at cost 12.

Who pays: once per login, or once per guess

The asymmetry is the point of the design. A real user logs in once, and pays the cost once. Even a slow check is a single short wait at a moment when the user expects a pause anyway.

An attacker working through a stolen database pays the cost on every guess. Guessing is a numbers game that only works when each attempt is nearly free. Multiply the price of one attempt by the millions of attempts a serious guessing run needs, and the cost factor is what turns an afternoon of cracking into weeks of computing time. That is why a fast hash such as SHA-256 must never be used for passwords: it hands the attacker guesses at almost no cost per try.

How to pick a cost, step by step

  1. Open the bcrypt Hash Generator and enter any password to experiment with.
  2. Generate a hash at cost 10 and notice how long the tool takes to answer.
  3. Repeat at cost 11 and cost 12. Feel the doubling: each step roughly doubles the wait. Note the warnings the tool shows at 11 and 12, because in a browser that extra work can freeze the tab.
  4. For a real application, measure on the production server, not your laptop. Raise the cost until one check takes roughly 250 ms there.
  5. Record the number you chose and revisit it as hardware improves. A cost that was right three years ago quietly gets cheaper for attackers every year.

Worked example: a timing ladder and a million guesses

Suppose a production server is tuned so that one check at cost 10 takes about 250 ms, the standard rule of thumb. The ladder then looks like this:

Cost 10: about 250 ms per check
Cost 11: about 500 ms per check
Cost 12: about 1 second per check

For a user, even the top of that ladder is one second at login: noticeable, but survivable. Now hand the same ladder to an attacker testing a million guesses against one stolen hash. At cost 10, a million checks at 250 ms each add up to roughly three days of continuous work. At cost 12, the same million guesses take roughly eleven and a half days. Only the dial moved, by two steps.

That is the entire argument for tuning cost carefully rather than accepting a default forever: two steps quadrupled the attacker's bill, at the price of a slightly slower login.

Limitations and honest tradeoffs

Cost is not free protection. Every legitimate login pays it too, so a cost set beyond what your server and users can bear trades security for a sign-in nobody enjoys. The tool's own range shows the practical ceiling in a browser: 4 to 12, with warnings at 11 and 12, while production systems commonly run 10 to 13 because a server can absorb more work than a browser tab.

Cost also cannot fix the other limits of bcrypt. Input is truncated at 72 bytes, so extra length past that point buys nothing. And the right number drifts: hardware improves, yesterday's 250 ms check gets faster, and a cost that is never re-tuned slowly stops meaning what it meant. Newer systems often choose Argon2id for its memory hardness and GPU resistance, but that is an argument about algorithm choice, not a claim that a tuned bcrypt cost has stopped working.

Common mistakes

  • Reading cost as a small linear scale. Ten and twelve look close; in time they are four times apart. Every step doubles.
  • Copying a cost from a tutorial. The correct cost is a timing measurement on your production server, targeting roughly 250 ms per check. Another machine's number is not yours.
  • Setting it once and forgetting it. Hardware improves every year, which quietly makes your stored cost cheaper for attackers. Re-tune on a schedule.
  • Cranking the cost to the maximum for safety. The defender pays too, on every login. Past the point users can feel, you are spending goodwill, not buying safety.
  • Judging cost in the browser tool alone. The bcrypt Hash Generator tops out at 12 and warns at 11; a production server's range can differ. Measure where hashes will actually be checked.

FAQs

What does the bcrypt cost factor actually change? It changes how much work bcrypt does internally before producing a result. Each step up doubles that work, so the time taken doubles too. The output format stays the same; only the effort, and therefore the delay, changes.

Why is cost 12 four times slower than cost 10, not twice as slow? Because the steps multiply rather than add. Going from 10 to 11 doubles the work once, and going from 11 to 12 doubles it again. Two doublings make four times the work, and four times the time.

What cost should a real application use? One that makes a single check take roughly 250 ms on the production server. On current hardware that commonly lands between cost 10 and 13. The right number is measured on your own server, not copied from a tutorial, and it should be re-tuned as hardware improves.

Why not set the cost as high as it will go? Because the defender pays the cost too, on every login. Push it far enough and sign-in becomes painfully slow for real users while the tab or server strains. In this tool, costs 11 and 12 already carry a warning because they can freeze a browser tab.

Is bcrypt still a good choice for new systems? Yes, bcrypt is still widely used and acceptable for password storage. Newer systems often choose Argon2id instead, because its memory hardness makes it harder to attack with GPUs, but a well-tuned bcrypt cost remains a sound defence.

Conclusion

The cost factor is a doubling dial, and small turns have large effects: cost 12 costs four times what cost 10 costs, for you once per login and for an attacker on every guess. Pick the number by timing a check on your own hardware, aim for roughly 250 ms, and revisit it as machines improve. To see the whole round trip the cost sits inside, read our guide on how to hash a password with bcrypt and check it later. For more guides in this series, see our Security and Privacy guides.

References