Skip to content
CryptographyInternals

01 / 11 · Modern cryptography

Brute force and key size

Why trying every key stops being an option once keys reach 128 bits.

Attack
Exhaustive key search
Cost
Doubles with every bit
Modern minimum
128-bit keys

Every cipher can be attacked by trying every possible key. Classical ciphers fall to it instantly: Caesar has 25 keys. Modern cryptography doesn't try to make brute force impossible. It makes it pointless, by choosing keys so large that the search can never finish.

Each extra bit doubles the number of keys. Below, your browser cracks small keys for real so you can feel that doubling, then the numbers are scaled up to the key sizes used today.

1,000 combinations
The numbers

10 × 10 × 10 = 1,000 combinations

01 / 14 · Brute force

A lock with 1,000 codes

A bike lock has three dials, each 0 to 9. A thief who doesn’t know the code can still turn the dials through every combination, 000, 001, 002…, until it opens.

The lock isn’t protected by a clever mechanism but by the number of combinations: 1,000 is a few minutes of patience.

Playground

How long would it take to try every key?

Pick a password shape or a key size, and how fast the attacker guesses. Then step through the arithmetic: each position multiplies the count, and the right panel works it out on your numbers.

Your input

8
10¹²

Drag for any speed, or pick an attacker:

Attacker
GPU cluster
Guesses per second
1 of 8 positions

261 =

26

keys · 2 digits · 24.7

Average time, log scale
1 s1 dayuniverse< 1 µs

average time to find it · 1 × 10¹²/s

Alphabet

One position, 26 choices

What happens

Each character of the password can be any of the 26 symbols of the alphabet you picked: a b c … z. The attacker who knows the alphabet only needs to try these.

On your values

1 position → 26 keys

log₂(26) = 4.7 bits per position

Why it matters

The alphabet sets what one position is worth, in bits: log₂ of the number of choices. That is the unit the rest of the arithmetic is counted in.

Start

Alphabet

Your browser against a small key

A message was encrypted with AES-128 under a random key, and the attacker knows every bit except the last 16. Your browser encrypts the known message with each candidate key until the output matches the ciphertext.

Unknown bits
Keys tried
– / 65,536
Time
–
Keys per second
–
Key found
–
Average time to find the key at your guess rate (log scale); your secret is highlighted
Caesar
< 1 µs
32 bits
2.1 ms
DES
10 hours
64 bits
107 days
80 bits
19,154 years
AES-128
5.4 × 10¹⁸ years
AES-256
1.8 × 10⁵⁷ years
Yours
104 ms
1 yearuniverse
Average time to find the key at your guess rate (log scale); your secret is highlighted
Caesar< 1 µs
32 bits2.1 ms
DES10 hours
64 bits107 days
80 bits19,154 years
AES-1285.4 × 10¹⁸ years
AES-2561.8 × 10⁵⁷ years
Yours104 ms

How it works

  1. 1A key of n bits can take 2ⁿ values.
  2. 2An attacker who knows a plaintext and its ciphertext tries keys one by one until one matches.
  3. 3On average the right key turns up after trying half of them: 2ⁿ⁻¹ attempts.
  4. 4Adding one bit to the key doubles the attacker's work; adding ten bits multiplies it by about a thousand.

Why it holds

Exponential growth
2¹²⁸ is about 3.4 × 10³⁸. Even at 10²¹ guesses per second (roughly the entire Bitcoin network's hash rate), the search takes about 5 × 10⁹ years on average. That's about 40% of the age of the universe, and AES-256 squares the problem.
Margin for the future
Each doubling of computing power buys an attacker exactly one bit. That is why 128 bits is the minimum today, and why 256-bit keys are recommended for data that must stay secret for decades.
No shortcuts known
Brute force only matters if nothing smarter exists. For AES, decades of public cryptanalysis have shaved off less than 2 bits.

What can go wrong

Short or guessable keys
DES used 56-bit keys and was brute-forced in 1998 by the EFF's DES Cracker in 56 hours. Keys derived from passwords are only as strong as the password.
Quantum computers
Grover's algorithm would square-root the search, turning 2¹²⁸ into 2⁶⁴ quantum steps. That is why long-term systems already favor 256-bit keys.
Read the in-depth articleHow Long Would It Take to Crack AES-256? The Real MathAt 10^21 guesses per second, brute-forcing AES-256 takes about 1.8 × 10^48 years. See the math, AES-128 vs AES-256, quantum, and what really breaks AES.