Cryptography Basic

Caesar / Shift Cipher

Shift every letter by the same amount: E(x) = x + k mod 26. Type a message to see it encrypt live, watch the alphabet mapping move, and use the brute-force panel to break a shift cipher without the key.

Live alphabet mapping
All 26 shifts ranked
Letter-by-letter working
Live
Message and Shift
Result
Ciphertext
Plaintext alphabet
Ciphertext alphabet (shifted by 3)
Only the 26 letters A–Z are shifted. Digits, spaces and punctuation are left alone, which is exactly why a shift cipher leaks word boundaries.
Letter-by-Letter Working
Break It: All 26 Shifts Ranked

Every possible key, scored by how closely its letter frequencies match English (chi-squared — lower is better). The best candidate is highlighted. Click any row to load that shift.

kDecryption with that keyScore
How the Shift Cipher Works
E(x) = (x + k) mod 26 D(y) = (y - k) mod 26

Number the letters A = 0, B = 1, …, Z = 25. Encryption adds the same key k to every letter and wraps around at Z. Decryption subtracts it.

Julius Caesar used k = 3, so A became D. ROT13 is the shift with k = 13 — and because 13 + 13 = 26, applying it twice returns the original text, which is why it is its own inverse.

The whole key space is just the 26 values of k, and k = 0 does nothing. So there are only 25 useful keys, and a computer tries all of them faster than you can read this sentence.

A shift cipher is a special case of the affine cipher with a = 1. Fixing a = 1 is exactly what shrinks the key space from 312 down to 26.
Why It Falls So Easily

Two separate weaknesses combine, and either one alone would be fatal:

  • The key space is tiny. 25 keys can be tried exhaustively — that is the brute-force panel above, and it is instant.
  • Letter frequencies survive. Shifting does not change how often each letter appears, it only relabels them. So the tall bar for E simply moves k places, and the shape of English is still visible.
  • Word shapes survive too. Leaving spaces in place hands over word lengths, and a three-letter word at the start of a sentence is very often THE.
This is the chapter-2 lesson in miniature: a cipher is only as strong as its key space and its ability to flatten the statistics of the plaintext. The shift cipher fails both tests.
Put It Into Practice

The tool shows the mechanism — the slides show why it is built that way.

Want to understand why this breaks?

The shift cipher is where cryptography starts and where cryptanalysis starts too. One-on-one tutoring walks you from frequency analysis all the way to RSA, with the reasoning intact at every step.

Book a Free Consultation →