Caesar Cipher

Encode, decode or try every Caesar shift. Choose 1–25, use shift 13 for ROT13, or select Brute Force Decoder.

Caesar cipher brute force: the short answer

A Caesar cipher has just 25 non-trivial keys. Trying all of them is effectively instant for a short message: decrypt with each shift from 1 to 25, then look for familiar words, sensible grammar and a coherent meaning. A low English-frequency score can point you to a candidate, but reading the whole result is the final check. Shift 0 would simply repeat the input.

Not sure it is Caesar? Try the cipher identifier.

Updated .

Worked example: rank every Caesar shift

Our plaintext is the public-domain opening sentence of Jane Austen's Pride and Prejudice (1813), chapter I, from Project Gutenberg's text. We join the source line break with a space and encrypt with shift 7, keeping case, spaces and punctuation. There are 92 A–Z letters to score.

It is a truth universally acknowledged, that a single man in possession of a good fortune must be in want of a wife.

Ciphertext to paste into the tool:

Pa pz h aybao bupclyzhssf hjruvdslknlk, aoha h zpunsl thu pu wvzzlzzpvu vm h nvvk mvyabul tbza il pu dhua vm h dpml.

Example computed 2026-10-29 with this page's codec.

The table scores the entire decrypted sentence, displaying only its first 40 characters. It sorts by the unrounded chi-squared score, lowest first; ties use the smaller shift. A listed shift is the encryption key being undone (subtract it to decrypt).

All 25 non-trivial Caesar shifts ranked by English chi-squared score
RankShiftχ² scoreFirst 40 characters
1714.029It is a truth universally acknowledged,
220355.827Vg vf n gehgu havirefnyyl npxabjyrqtrq,
319374.539Wh wg o hfihv ibwjsfgozzm oqybckzsrusr,
415416.708Al ak s ljmlz mfanwjksddq sucfgodwvywv,
513473.558Cn cm u nlonb ohcpylmuffs uwehiqfyxayx,
66644.287Ju jt b usvui vojwfstbmmz bdlopxmfehfe,
718662.072Xi xh p igjiw jcxktghpaan przcdlatsvts,
83679.237Mx mw e xvyxl yrmzivweppc egorsapihkih,
914702.370Bm bl t mknma ngboxklteer tvdghpexwzxw,
109810.106Gr gq y rpsrf slgtcpqyjjw yailmujcbecb,
115848.504Kv ku c vtwvj wpkxgtucnna cempqyngfigf,
1223848.518Sd sc k dbedr exsfobckvvi kmuxygvonqon,
1325872.139Qb qa i bzcbp cvqdmzaittg iksvwetmloml,
1411955.645Ep eo w pnqpd qjeranowhhu wygjkshazcaz,
15241124.511Rc rb j cadcq dwrenabjuuh jltwxfunmpnm,
1641137.007Lw lv d wuxwk xqlyhuvdoob dfnqrzohgjhg,
17221188.967Te td l ecfes fytgpcdlwwj lnvyzhwporpo,
1811218.976Oz oy g zxazn atobkxygrre giqtucrkjmkj,
19171268.781Yj yi q jhkjx kdyluhiqbbo qsadembutwut,
2021337.129Ny nx f ywzym zsnajwxfqqd fhpstbqjilji,
2181341.269Hs hr z sqtsg tmhudqrzkkx zbjmnvkdcfdc,
22101385.385Fq fp x qorqe rkfsbopxiiv xzhkltibadba,
23121481.664Do dn v ompoc pidqzmnvggt vxfijrgzybzy,
24161595.148Zk zj r kilky lezmvijrccp rtbefncvuxvu,
25211931.346Uf ue m fdgft gzuhqdemxxk mowzaixqpsqp,

Winning shift: 7; χ² = 14.029. Its full result matches Austen's sentence above. You can reproduce it with Decode at shift 7.

How the score is calculated

χ² = Σ (Oᵢ − Eᵢ)² / Eᵢ; Eᵢ = N × fᵢ / Σ f

For each letter A–Z, Oᵢ is its observed count, N is the total letter count and fᵢ is its reference English frequency. We use the same rounded Lewand frequency table as the site's frequency analysis tool, sourced from the letter frequency reference. Dividing by the sum normalizes those rounded frequencies. Case, punctuation, spaces and digits are ignored.

Lower means a closer letter distribution, not a probability that the text is correct. This is a ranking heuristic, not a statistical significance test. It does not check word order or meaning, and assumes English plaintext written with A–Z.

What changes when the ciphertext gets shorter?

Keep the same ciphertext and shift, remove non-letters, uppercase it, and take its first 40, 20, 10, 5 and 4 letters. Rank the same 25 candidate shifts each time. These are measured outputs for this one sentence.

Frequency ranking on progressively shorter prefixes of the same ciphertext
LettersTop shiftTop χ²Top plaintextTrue shift rankTrue shift χ²
40712.514ITISATRUTHUNIVERSALLYACKNOWLEDGEDTHATASI112.514
20719.586ITISATRUTHUNIVERSALL119.586
10715.328ITISATRUTH115.328
5714.270ITISA114.270
42214.800TETD217.034

In the displayed samples, the original shift stays first down to 5 letters. At 4 letters, the score favors shift 22 (“TETD”), while the true shift 7 ranks 2. A few letters can fit the reference distribution by chance. This illustrates the method's sampling limit, not a universal cutoff: another sentence or another prefix can change the order. Compare scores within a row, not across different lengths.

For a short message, inspect every candidate and use word boundaries or surrounding context. More ciphertext from the same key gives the frequency comparison more evidence; a longer sample still does not guarantee that the first-ranked result is right.

Brute-force attacks on classical ciphers: key spaces

Count the allowed keys before planning an exhaustive search. This comparison assumes the 26-letter alphabet and 1,000,000,000 keys/second (10⁹) for every cipher. This is an illustrative assumed rate, not a browser benchmark or a measured cracking speed.

Time to try every key = key count ÷ 10⁹ seconds

Exhaustive search times at an assumed billion keys per second
CipherKey-space formulaKeysTime for every key
ROT131 fixed shift (13)11 ns
Atbash1 fixed reversed alphabet11 ns
Caesar26 − 1 (exclude shift 0)2525 ns
Affine (all key pairs)12 × 26312312 ns
Affine (non-identity)12 × 26 − 1311311 ns
Keyword / simple substitution26! = 26 × 25 × … × 1≈ 4.03 × 10^26≈ 1.28 × 10^10 years
Vigenère (n = 3)26^317,57617.576 μs
Vigenère (n = 5)26^511,881,37611.8814 ms
Vigenère (n = 8)26^8208,827,064,5763.480 minutes

ROT13 and Atbash each fix one mapping. For Affine, y = ax + b (mod 26): a must be coprime to 26, giving 12 multipliers, while b has 26 choices. That makes 312 pairs; excluding just (a, b) = (1, 0) gives 311 non-identity pairs, including the 25 non-trivial Caesar shifts. See the Affine cipher derivation.

For simple substitution, there are 26 choices for the first replacement letter, 25 for the next, and so on: 26! alphabets, including the identity. The keyword row counts unrestricted substitution alphabets; searching only dictionary keywords would be a smaller, dictionary-dependent task. Different keywords can produce the same alphabet.

For Vigenère, a key of exactly n letters has 26ⁿ possible strings, including strings with a shorter repeating period and the all-A identity. If n is unknown, search each candidate length as well. Times here cover every key, not an average successful search; years use 365.25 days. The calculation omits message length, scoring cost and hardware differences, so equal rates do not imply equal real workloads.

The huge substitution space does not make it modern security: frequency and word-pattern attacks avoid enumerating every alphabet. Use the frequency analysis tool to inspect those patterns.

How to use Brute Force Decoder on this page

  1. In the tool's Mode menu, choose Brute Force Decoder.
  2. Paste ciphertext into Input Text. All 25 non-trivial decryptions appear in the output automatically.
  3. Read the list in shift order, 1–25. The tool lists candidates; it does not calculate or rank scores. The worked tutorial table above is separately ranked by English frequency.
  4. Use Copy or Download to save the full list. The shift slider and Swap are disabled in this mode.
  5. For just one result, choose Decode and set Shift Value to the candidate's shift. For ROT13, set it to 13.

Encode adds the shift; Decode subtracts it, wrapping around A–Z. For example, shift 3 maps A to D and Z to C. Case, spaces, digits and punctuation are preserved. Applying shift 13 twice makes a full 26-letter turn, which is why the same operation encodes and decodes ROT13.

History and sources

Suetonius describes Caesar replacing A with D and the remaining letters in the same way in private correspondence (Life of Julius Caesar, 56). That is the shift-3 pattern associated with his name. The example here uses the modern 26-letter English alphabet and shift 7 so you can follow a different key through encryption and recovery.

Frequently asked questions

How do I use a Caesar cipher brute force decoder?

Select Brute Force Decoder in the Mode menu and paste the ciphertext. The output lists shifts 1–25 in numeric order; it does not rank them. Read the candidates for sensible words and grammar. Copy and Download save the whole list. To isolate one result, choose Decode and set its shift.

How many keys does a Caesar cipher have?

For the 26-letter English alphabet there are 26 shifts if you include shift 0, which leaves the text unchanged. Excluding that identity gives 25 non-trivial keys. Shift 26 is the same as shift 0, not an extra key.

How does Caesar cipher brute force find the right shift?

Try each shift and compare the resulting text with English. The worked table ranks candidates by chi-squared letter frequency: lower is closer to the reference distribution. Its winning shift is 7, with a score of 14.029. Confirm the words and meaning; the score is not a probability or a guarantee.

Do I need brute force to decode ROT13?

ROT13 specifies shift 13, so there is only one transformation to try. Choose Decode and set Shift Value to 13. Applying ROT13 a second time restores the original text. If you only know the message is a Caesar cipher, try all 25 non-trivial shifts, including 13.

Why can frequency ranking choose a different shift for short text?

Short samples have uneven letter counts, so the closest English-frequency match need not be the original text. In the displayed prefixes, shift 7 ranks first at 40, 20, 10 and 5 letters; at 4 letters, shift 22 ranks first and the original shift ranks 2. This is a property of this sample and scoring method, not a universal length cutoff.

Can you brute force a substitution cipher?

In principle, yes: an unrestricted substitution over A–Z has 26! possible alphabets, about 4.03 × 10^26. Exhaustively trying them is impractical even at the assumed billion keys per second in the comparison table. Solvers instead use letter frequencies, word patterns and heuristic searches. A dictionary-only keyword search covers a smaller set than all substitution alphabets.