TExcelTAD
Home › Applied Cryptography: Ciphers, Hashes, Signatures, PKI & TLS › Password Entropy and the Cost of Guessing

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 LL is chosen uniformly at random from an alphabet of CC symbols, there are CLC^L equally likely passwords and its entropy is

H=log⁡2(CL)=Llog⁡2C bitsH = \log_2 \left( C^L \right) = L \log_2 C \ \text{bits}

An attacker who tries passwords in any order expects to succeed after searching half the space, so the expected time at RR guesses per second is

T=CL2R=2H−1RT = \frac{C^L}{2R} = \frac{2^{H - 1}}{R}

Examples: 10 characters from 62 letters and digits give 10log⁡262≈59.510 \log_2 62 \approx 59.5 bits. Six words from the 7,776-word Diceware list give 6log⁡27776≈77.56 \log_2 7776 \approx 77.5 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 HH, 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".

10 random characters from 62 a–z A–Z 0–9entropy H = L · log2 C = 10 · 5.954 = 59.5 bitssearch space C^L = 62^10 = 8.39 × 10¹⁷ guessesguess rate R ≈ 10¹⁰ /s (offline, one GPU, SHA-256 (fast))expected time C^L / (2R) ≈ 1.3 yearsrates: illustrativeorders of magnitude,not benchmarkssecondhourdayyearcenturyuniverse age10⁻³ s10³ s10⁹ s10¹⁵ s10²¹ s14812162024expected time (log scale)SHA-256PBKDF2 600kbcrypt 12L = 10: 1.3 yearslength L →

With the defaults the expected time is about 1.3 years against unsalted SHA-256 on one GPU, and about 1.3×1071.3 \times 10^7 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, 101010^{10} per second for SHA-256 on one GPU, 10410^4 for PBKDF2-HMAC-SHA256 with 600,000 iterations and 10310^3 for bcrypt with cost 12.

python · try it yourself
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:

  1. 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).
  2. 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 10610^6 to 10710^7 for every single password.
  3. 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?

5log⁡27776≈64.65 \log_2 7776 \approx 64.6 bits; 77765/(2×1010)≈1.4×1097776^5 / (2 \times 10^{10}) \approx 1.4 \times 10^9 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?

  1. About 10 bits
  2. About 59.5 bits
  3. About 62 bits
  4. About 620 bits

Why is the entropy formula misleading for human-chosen passwords?

  1. Humans use longer passwords
  2. Human choices are far from uniform, so dictionaries find them much faster
  3. It ignores the salt
  4. It counts characters twice

In the table, how long does an 8-character lowercase password last against unsalted SHA-256 on one GPU?

  1. 10 seconds
  2. 3.8 days
  3. 3.3 years
  4. Thousands of years

Which change multiplies an offline attacker's cost per guess by about a million?

  1. Adding a symbol requirement
  2. Storing passwords with a slow password hash such as bcrypt or Argon2id instead of SHA-256
  3. Using a salt with SHA-256
  4. Forcing password changes every 90 days