Password Entropy and the Cost of Guessing
After a breach, the question for every stored password is: how long until the attacker has guessed it? The answer depends on three numbers, and the defender controls two of them. The size of the search space depends on the password; the number of guesses per second depends on where the attacker guesses (online against the login page, or offline against a stolen hash database) and on which hash was used to store the password. This lesson puts numbers on all three. No real hash is cracked: everything is arithmetic.
Entropy of a random password
If a password of length is chosen uniformly at random from an alphabet of symbols, there are equally likely passwords and its entropy is
An attacker who tries passwords in any order expects to succeed after searching half the space, so the expected time at guesses per second is
Examples: 10 characters from 62 letters and digits give bits. Six words from the 7,776-word Diceware list give bits, more than 12 random letters and digits and much easier to remember.
Uniformly at random is the crucial condition. Human-chosen passwords are not uniform: Summer2026! has 11 characters from 95 symbols, a nominal 72 bits, but it is among the first few million guesses of any cracking dictionary with rules. For human-chosen passwords the formula gives an upper bound that is usually wildly optimistic; this is why NIST SP 800-63B dropped composition rules (one upper-case letter, one symbol…) in favour of length, blocklists of common and breached passwords, and rate limiting.
The lab
The lab computes , the search space and the expected time for an alphabet, a length, an attacker and a hash. Start with the defaults (62 symbols, length 10, one GPU, SHA-256), then change the hash to PBKDF2 and bcrypt, and the attacker to "online".
With the defaults the expected time is about 1.3 years against unsalted SHA-256 on one GPU, and about years against bcrypt with cost 12, because each guess is about ten million times more expensive. The guess rates in the lab are illustrative orders of magnitude, not benchmarks: real rates depend on hardware and parameters and grow every year.
The same arithmetic in Python
The table below uses the same illustrative rates: 1 guess per second for a rate-limited online attack, per second for SHA-256 on one GPU, for PBKDF2-HMAC-SHA256 with 600,000 iterations and for bcrypt with cost 12.
import math
YEAR = 3.156e7
RATES = {"online": 1, "SHA-256": 1e10, "PBKDF2": 1e4, "bcrypt": 1e3} # guesses per second
POLICIES = [("8 lowercase letters", 26, 8), ("8 chars, full printable ASCII", 95, 8),
("12 chars a-z A-Z 0-9", 62, 12), ("4 Diceware words", 7776, 4), ("6 Diceware words", 7776, 6)]
def fmt(seconds):
for unit, s in (("years", YEAR), ("days", 86400), ("hours", 3600), ("s", 1)):
if seconds >= s:
return f"{seconds / s:.2g} {unit}"
return f"{seconds:.2g} s"
print(f"{'policy':30} {'bits':>5} " + " ".join(f"{k:>13}" for k in RATES))
for name, c, length in POLICIES:
bits = length * math.log2(c)
space = c ** length
times = [fmt(space / 2 / r) for r in RATES.values()]
print(f"{name:30} {bits:5.1f} " + " ".join(f"{t:>13}" for t in times))policy bits online SHA-256 PBKDF2 bcrypt
8 lowercase letters 37.6 3.3e+03 years 10 s 1.2e+02 days 3.3 years
8 chars, full printable ASCII 52.6 1.1e+08 years 3.8 days 1.1e+04 years 1.1e+05 years
12 chars a-z A-Z 0-9 71.5 5.1e+13 years 5.1e+03 years 5.1e+09 years 5.1e+10 years
4 Diceware words 51.7 5.8e+07 years 2.1 days 5.8e+03 years 5.8e+04 years
6 Diceware words 77.5 3.5e+15 years 3.5e+05 years 3.5e+11 years 3.5e+12 years
Three lessons are in this table:
- Online guessing is slow if it is rate-limited: even 8 lowercase letters take thousands of years at one guess per second. Online attacks succeed through credential stuffing (passwords from other breaches) and password spraying (a few common passwords against many accounts), not exhaustive search (Brute Force and Password Spraying).
- Offline, the hash decides. The same 8-character password takes 10 seconds against SHA-256 and 3.3 years against bcrypt. A slow, salted password hash multiplies the attacker's cost by to for every single password.
- Length beats complexity. Going from 8 random lowercase letters to 8 random printable characters adds 15 bits; four Diceware words give about the same, and six words are out of reach for every attacker in the table.
How weak password setups are detected
- Storage audit: which algorithm and parameters are in the database (
$2b$12$…is bcrypt cost 12,$argon2id$v=19$m=19456,t=2,p=1$…, a bare 64-hex-digit string is probably unsalted SHA-256); hashes with too low a cost; hashes shared by many users (no salt). - Policy audit: maximum lengths (anything below 64 characters is a red flag), composition rules instead of blocklists, no rate limiting or lockout on login, password hints.
- Breach exposure: checking users' passwords against known-breached lists at registration and login (k-anonymity APIs such as Have I Been Pwned's range API send only a 5-character hash prefix).
- Login telemetry: many failures across many accounts from one source (spraying), or successful logins from new devices right after failures.
How it is fixed
- Store passwords with Argon2id, scrypt or bcrypt at current parameters (Password Storage).
- Allow long passwords (at least 64 characters) and passphrases; require a minimum length (NIST SP 800-63B-4 requires at least 15 characters when a password is the only factor, 8 with MFA); block common and breached passwords; drop composition rules and forced periodic changes.
- Rate-limit and monitor online attempts; add MFA, preferably phishing-resistant (passkeys, FIDO2).
- Encourage password managers, which generate uniform random passwords where the entropy formula really applies.
Pitfalls
- Using the entropy formula for human-chosen passwords: it measures the generator, not the person.
- Meters that reward
P@ssw0rd!for its symbols; a good meter (zxcvbn and similar) estimates guesses from dictionaries and patterns. - Forgetting that a fast hash with a salt is still fast: salts stop precomputed tables and multi-target attacks, not per-password guessing.
Practice
1. How many bits does a 5-word Diceware passphrase have, and how long would it take at $10^{10}$ guesses per second?
bits; seconds, about 45 years on one GPU against SHA-256, and hundreds of millions of years against bcrypt.
2. In the lab, switch the attacker to "online" with the defaults. Why do the hash choices no longer matter?
Online, the server rate-limits guesses to about one per second; the attacker never sees the hash, so its cost is irrelevant. The hash matters only after a breach, offline.
3. A site requires 8–12 characters with one digit and one symbol. What would you change?
Raise the maximum to at least 64, set a minimum of 15 (or 8 with MFA), remove composition rules, add a breached-password blocklist, rate-limit logins and store passwords with Argon2id.
Practice problem in 21 languages: Password Entropy Estimate.
Test yourself
What is the entropy of a uniformly random 10-character password over 62 symbols?
- About 10 bits
- About 59.5 bits
- About 62 bits
- About 620 bits
Why is the entropy formula misleading for human-chosen passwords?
- Humans use longer passwords
- Human choices are far from uniform, so dictionaries find them much faster
- It ignores the salt
- It counts characters twice
In the table, how long does an 8-character lowercase password last against unsalted SHA-256 on one GPU?
- 10 seconds
- 3.8 days
- 3.3 years
- Thousands of years
Which change multiplies an offline attacker's cost per guess by about a million?
- Adding a symbol requirement
- Storing passwords with a slow password hash such as bcrypt or Argon2id instead of SHA-256
- Using a salt with SHA-256
- Forcing password changes every 90 days