Skip to content
CodeShift
Menu

How to Crack a Caesar Cipher

Two methods crack a Caesar cipher: try all 25 shifts (brute force) or use frequency analysis — E appears in 12.7% of English text.

By The CodeShift DeskUpdated October 7, 2026

Cracking a Caesar cipher takes at most 25 guesses. Because the only secret is the shift amount (an integer from 1 to 25), you can simply try every possibility and read the output. For longer texts, frequency analysis finds the shift directly from the letter counts in the ciphertext.

Method 1: Brute Force

Write out all 25 possible decryptions of your ciphertext and read for sense. One of the 25 will be recognizable English.

Example ciphertext: KHOOR ZRUOG

Shift Decryption
1 JGNNQ YQTNF
2 IFMMP XPSME
3 HELLO WORLD
4 GDKKN VNQKC
… …

Shift 3 produces readable English: HELLO WORLD. Done.

The Caesar cipher tool automates this — paste in ciphertext and it can show all 25 decryptions at once.

Method 2: Frequency Analysis

For longer messages, count how often each letter appears in the ciphertext. Then compare to the known distribution of English letters.

Standard English letter frequencies (top 12):

Letter Approximate frequency
E 12.7%
T 9.1%
A 8.2%
O 7.5%
I 7.0%
N 6.7%
S 6.3%
H 6.1%
R 6.0%
D 4.3%
L 4.0%
C 2.8%

If the most common letter in your ciphertext is X, and you assume it encrypts E (the most common English letter), the shift is X minus E = 23 minus 4 = 19. Test that shift against the full ciphertext. If the result reads as English, you have the key. If not, try assuming the ciphertext’s most common letter encrypts T, N, or A.

Step-by-Step Worked Example

Ciphertext: WKH TXLFN EURZQ IRA

  1. Count letter frequencies. H appears twice — the highest count in this short text.
  2. Assume H encodes E (the most frequent English letter): shift = H(7) − E(4) = 3.
  3. Subtract 3 from every letter position (add 26 if the result goes below 0):
Cipher Position −3 Plain
W 22 19 T
K 10 7 H
H 7 4 E
T 19 16 Q
X 23 20 U
L 11 8 I
F 5 2 C
N 13 10 K
E 4 1 B
U 20 17 R
R 17 14 O
Z 25 22 W
Q 16 13 N
I 8 5 F
R 17 14 O
A 0 23 X

Plaintext: THE QUICK BROWN FOX ✓

What Frequency Analysis Cannot Do

Frequency analysis struggles with:

  • Messages shorter than about 30 characters (too little data)
  • Messages with unusual vocabulary (all-caps acronyms, proper nouns)
  • Deliberately skewed text (a “lipogram” — text that avoids common letters)

For a single short phrase, just try all 25 shifts. For a longer text, frequency analysis is faster.

Why This Matters

Al-Kindi described frequency analysis in the 9th century — his manuscript Risalah fi Istikhraj al-Mu’amma (“A Manuscript on Deciphering Cryptographic Messages”) is held in the Süleymaniye Library in Istanbul and is widely cited by cryptography historians, including David Kahn in The Codebreakers (Scribner, 1996), as the oldest known document on breaking ciphers. Understanding it explains why all modern encryption uses keys that are far too large to try by brute force and mixes multiple operations to flatten letter frequencies.

See Caesar Cipher Explained for the encryption side, or Vigenère Cipher Explained for a cipher that partially resists frequency analysis.

Frequently asked questions

How long does it take to crack a Caesar cipher?+

Manually, checking all 25 shifts takes a few minutes. A computer breaks any Caesar cipher in milliseconds.

What is frequency analysis?+

Frequency analysis counts how often each letter appears in a ciphertext. Because natural languages have predictable letter distributions, the counts reveal the shift without trying all possibilities.

Who invented frequency analysis?+

The 9th-century Arab scholar Al-Kindi described frequency analysis in his manuscript 'A Manuscript on Deciphering Cryptographic Messages' — the earliest known document on breaking ciphers.

Does frequency analysis work on short messages?+

Less reliably. In very short messages (under 30 characters), the letter distribution may not match the expected pattern. Brute force is more reliable for short ciphertext.

Can I crack a Vigenère cipher the same way?+

Not directly. A Vigenère cipher uses different shifts for different letters, which flattens the frequency distribution. You first need to find the key length using the Kasiski test or index of coincidence.

Keep reading