Classical Ciphers - Where Cryptography Began
Long before computers, before the internet, even before electricity, people needed to keep secrets. Military commanders needed to send orders without the enemy understanding them. Lovers wanted to exchange messages privately. Diplomats needed to communicate sensitive information across hostile territory.
The solution? Cryptography. But not the complex mathematical algorithms we use today - these were simple ciphers that anyone could perform with just paper and pencil. Some were so simple that even a child could use them. Yet despite their simplicity, these classical ciphers laid the foundation for everything we use today.
Let’s meet our familiar friends Alice, Bob, and Trudy, but this time, let’s imagine they’re living in ancient Rome, medieval Europe, or the 1800s. No computers, no electricity - just clever thinking and creativity.
The Caesar Cipher: Where It All Started
The story begins over 2,000 years ago with Julius Caesar. He had a problem: he needed to send military orders to his generals, but if the messenger was captured by enemies, they’d read his plans and know exactly what he was going to do.
Caesar’s solution was brilliantly simple: shift every letter in the alphabet by a fixed number of positions.
How It Works
Imagine the alphabet as a circle. To encrypt a message, you simply shift each letter forward by a certain number of positions. That number is your key.
Let’s say Alice wants to send Bob a message: "ATTACK AT DAWN"
She decides to use a shift of 3 (shift each letter 3 positions forward):
Plain alphabet: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Cipher alphabet: D E F G H I J K L M N O P Q R S T U V W X Y Z A B C
↑ (shifted by 3)
#


Now she encrypts each letter:
- A → D
- T → W
- T → W
- A → D
- C → F
- K → N
And so on. The encrypted message becomes: "DWWDFN DW GDZQ"
A Real Example
Alice: "Bob, I need to send you our plans. Let’s use Caesar cipher with key 3."
Original message: MEET ME AT THE FORUM Encrypted message: PHHW PH DW WKH IRUXP
Alice sends "PHHW PH DW WKH IRUXP" to Bob.
Bob receives it and shifts each letter backwards by 3:
- P → M
- H → E
- H → E
- W → T
And he gets: "MEET ME AT THE FORUM"
Perfect! The message got through safely.
private static String encrypt(String message, int key) {
StringBuilder encrypted = new StringBuilder();
for (char ch : message.toCharArray()) {
char encryptedChar = (char) ((int) ch + key);
encrypted.append(encryptedChar);
}
return encrypted.toString();
}
The Problem: Trudy Gets Smart
But here’s where things get interesting. Trudy has been intercepting these messages for weeks. She doesn’t know the key, but she’s clever. She thinks: "There are only 25 possible shifts (we don’t count 0, that’s no encryption at all). I could just try all 25 and see which one makes sense!"
She intercepts: "PHHW PH DW WKH IRUXP"
She tries shift 1: OGGV OG CV VJG HQTWP (nonsense) She tries shift 2: NFFU NF BU UIF GPSVN (nonsense) She tries shift 3: MEET ME AT THE FORUM (aha!)
It took her less than a minute to break the cipher. This is called a brute force attack - trying every possible key until you find the right one.
Why Caesar Cipher Fails
The Caesar cipher has a fatal weakness: there are only 25 possible keys. Even without a computer, Trudy can try all of them in a few minutes. With a computer? Instantly.
But it teaches us something important: the keyspace matters. A larger keyspace (more possible keys) makes brute force attacks harder.
Key Takeaway: The Caesar cipher introduced the concept of a key, but with only 25 possibilities, it’s far too weak for real security.
The Substitution Cipher: More Keys, Same Problem
So cryptographers thought: "What if instead of just shifting, we scramble the entire alphabet randomly?"
How It Works
Instead of shifting every letter by the same amount, you create a completely random mapping of each letter to another letter.
For example:
Plain alphabet: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Cipher alphabet: Q W E R T Y U I O P A S D F G H J K L Z X C V B N M
Now the keyspace is HUGE. There are 26! (26 factorial) possible ways to arrange 26 letters. That’s:
403,291,461,126,605,635,584,000,000 possible keys!
Good luck trying all of those, Trudy!
Example
Alice and Bob agree on this substitution key:
Plain: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Cipher: Z Y X W V U T S R Q P O N M L K J I H G F E D C B A
(This is actually a simple reversal - A becomes Z, B becomes Y, etc.)
Original message: SEND HELP Encrypted: HVMW SVOK
Alice sends "HVMW SVOK" to Bob, and Bob uses the same key to decrypt it back to "SEND HELP".
The Problem: Frequency Analysis
Trudy intercepts the message "HVMW SVOK" but she doesn’t know the key. Can she still break it?
With a short message like this, probably not. But what if Alice and Bob exchange hundreds of messages? What if Trudy collects a whole book encrypted with the same key?
Here’s the clever part: in English, some letters appear more often than others.
The most common letter in English is E (appears about 12.7% of the time). Then comes T, A, O, I, N, S, H, R…
So Trudy does this:
- Counts how often each letter appears in the encrypted messages
- The most frequent letter in the ciphertext is probably E
- The second most frequent is probably T
- And so on…
Let’s say Trudy intercepts a longer message:
Ciphertext: "SVOOL! RU BLF DZMG GL OVZIM ZILFG XIBKGLTIZKSB? SVIV RH Z HVXIVG NVHHZTV"
She counts the letters:
- V appears 8 times (most common)
- G appears 7 times
- L appears 7 times
- Z appears 6 times
In English, E is most common, so V is probably E. T is second most common, so maybe G or L is T. She makes educated guesses:
V → E G → T L → O Z → A
Now the message starts to reveal itself: "SEOO_! __ O ANT TO OEA_N A_O_T __YPT_T_APH? HE_E _S A SE__ET NESSA_E"
She can start guessing the missing letters from context: "HELLO! DO YOU WANT TO LEARN ABOUT CRYPTOGRAPHY? HERE IS A SECRET MESSAGE"
The key was:
Plain: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Cipher: Z Y X W V U T S R Q P O N M L K J I H G F E D C B A
Key Takeaway: Even with trillions of possible keys, the substitution cipher fails because it preserves patterns. The structure of language leaks through the encryption.
Real-World Example: The Zodiac Killer
This isn’t just theoretical. The Zodiac Killer in California (late 1960s) sent encrypted messages to newspapers using substitution ciphers. Amateur cryptographers broke them using frequency analysis, even though the killer tried to be clever by using symbols instead of letters.
The Vigenère Cipher: The "Unbreakable" Cipher
For centuries, there was a cipher that was considered unbreakable. It was called "le chiffre indéchiffrable" - the indecipherable cipher. This was the Vigenère cipher, invented in the 16th century but not broken until the 19th century.
How It Works
The Vigenère cipher is like using multiple Caesar ciphers in sequence. Instead of one shift value, you use a keyword, and each letter of the keyword tells you how much to shift.
Let’s say Alice and Bob agree on the keyword: "KEY"
First, convert the keyword to numbers (A=0, B=1, C=2… K=10, E=4, Y=24):
- K = 10
- E = 4
- Y = 24
Now encrypt the message "ATTACK AT DAWN" by repeating the keyword:
Message: A T T A C K A T D A W N
Keyword: K E Y K E Y K E Y K E Y
Shifts: 10 4 24 10 4 24 10 4 24 10 4 24
For each position:
- A + shift 10 = K
- T + shift 4 = X
- T + shift 24 = R
- A + shift 10 = K
- C + shift 4 = G
- K + shift 24 = I
Encrypted message: KXRK GI KX RKHB
Why It’s Stronger
Notice what happened here: the letter A appears three times in "ATTACK AT DAWN", but it’s encrypted as K, K, and K. Wait, that’s the same. Let me recalculate…
Actually, let’s use a clearer example:
Message: HELLO HELLO HELLO Keyword: ABC (shifts: 0, 1, 2)
Message: H E L L O H E L L O H E L L O
Keyword: A B C A B C A B C A B C A B C
Result: H F N L P H F N L P H F N L P
See? The three H’s became H, H, and H (all shifted by A=0) The three E’s became F, F, and F (all shifted by B=1) The three L’s became N, N, and N (all shifted by C=2)
Hmm, that’s still showing a pattern. Let me try a better example:
Message: THE THE THE Keyword: KEY
Message: T H E T H E T H E
Keyword: K E Y K E Y K E Y
Shifts: 10 4 24 10 4 24 10 4 24
Result: D L C D L C D L C
Wait, this is still repeating because the message has a repeating pattern. Let me try with a non-repeating message:
Message: MEET ME AT THE PARK Keyword: KEY (K=10, E=4, Y=24)
M E E T M E A T T H E P A R K
K E Y K E Y K E Y K E Y K E Y
----------------------
W I C D Q C K X R R I N K V I
Now look: the three E’s in the original message become I, C, and C. Not all the same! The two M’s become W and Q. The pattern is broken!
Why This Was Considered Unbreakable
Frequency analysis doesn’t work anymore because the same letter can be encrypted differently depending on where it appears. The letter E might become C in one position, I in another, and M in yet another.
For about 300 years, people thought this was truly unbreakable. It was used by the Confederacy during the American Civil War and various European militaries.
The Problem: Patterns Still Exist
But then, in the 19th century, a brilliant cryptographer named Friedrich Kasiski figured out how to break it.
Here’s the weakness: the keyword repeats.
If Trudy intercepts a long message, she might notice that some sequences of letters repeat at regular intervals. For example, if "WIC" appears multiple times in the ciphertext, and they’re always 9 letters apart, that’s a clue! The keyword length might be 3 (or 9, or a factor of the distance).
Once Trudy knows the keyword length, she can split the message into groups:
- Every 1st, 4th, 7th, 10th… letter was encrypted with K
- Every 2nd, 5th, 8th, 11th… letter was encrypted with E
- Every 3rd, 6th, 9th, 12th… letter was encrypted with Y
Now each group is just a simple Caesar cipher! She can use frequency analysis on each group separately.
A Real Example of Breaking Vigenère
Trudy intercepts this ciphertext:
"KIKCPXSEKIKCPXMEKQVXSSWOVFBRKIKCPXSEOI"
She notices "KIKCPX" appears three times, and they’re 12 letters apart. The keyword is probably 3, 4, 6, or 12 letters long.
She tries assuming it’s 3 letters. She splits the message into three groups:
Group 1 (positions 1, 4, 7, 10…): K C X K C X K C X O K C X O Group 2 (positions 2, 5, 8, 11…): I P S I P M I S W I I P S Group 3 (positions 3, 6, 9, 12…): K S E K S E Q V S V F B R E I
Looking at Group 1, K appears 4 times. If K is actually A (the most common letter), then the shift for this position is 10 (K is the 10th letter after A). So the first letter of the keyword is K!
She does the same for the other groups and discovers the keyword is "KEY".
Key Takeaway: The Vigenère cipher was a huge improvement, but the repeating keyword created patterns that could eventually be detected in long messages.
The One-Time Pad: Perfect Security (At A Cost)
Cryptographers looked at the Vigenère cipher and thought: "The problem is the repeating keyword. What if we use a keyword that’s as long as the message itself and never reuse it?"
This is called a one-time pad, and it’s mathematically proven to be unbreakable. Not "really hard to break" - actually impossible to break.
How It Works
Alice and Bob need to share a key that’s:
- As long as the message
- Completely random
- Used only once
- Kept completely secret
Alice’s message: HELLO (5 letters) Random key: XMCKL (5 completely random letters)
Convert both to numbers (A=0, B=1, C=2…):
Message: H E L L O = 7 4 11 11 14
Key: X M C K L = 23 12 2 10 11
Add: 30 16 13 21 25 (if >= 26, subtract 26)
Result: E Q N V Z
Encrypted message: EQNVZ
Bob receives "EQNVZ" and subtracts the same key to get "HELLO" back.
Why It’s Unbreakable
Here’s the amazing thing: Trudy intercepts "EQNVZ" but doesn’t know the key. She tries to guess what key might produce "EQNVZ".
But with a truly random key, "EQNVZ" could decrypt to literally ANY 5-letter message:
- EQNVZ - key AAAAA → EQNVZ
- EQNVZ - key XMCKL → HELLO
- EQNVZ - key TRPEM → LATER
- EQNVZ - key NJFUW → NEVER
- EQNVZ - key GHTQD → ABORT
Every possible message is equally likely! Trudy gains zero information from the ciphertext.
This was proven mathematically by Claude Shannon in 1949. The one-time pad provides perfect secrecy.
The Massive Problem
So why doesn’t everyone use one-time pads? Because they’re completely impractical:
Problem 1: Key Distribution Alice and Bob need to secretly exchange a key that’s as long as all the messages they’ll ever send. If they can securely exchange that much data, why not just securely exchange the messages themselves?
Problem 2: Key Storage Want to send a 1 GB file? You need a 1 GB random key. That’s a lot to store securely.
Problem 3: Synchronization Alice and Bob must keep track of which part of the key they’ve used. If they get out of sync, every message after that is garbage.
Problem 4: No Key Reuse The moment you reuse any part of the key, the security breaks. During WWII, Soviet spies reused parts of one-time pads. The US decrypted thousands of messages in the "Venona Project".
Real-World Use
Despite the problems, one-time pads have been used:
- The Washington-Moscow hotline during the Cold War
- Spy agencies for critically important messages
- Some diplomatic communications
They physically transported briefcases full of random keys. It worked because the volume of messages was small and the stakes were extremely high.
Key Takeaway: Perfect security exists, but it’s impractical. Real-world cryptography is about finding a balance between security and usability.
The Transition to Modern Cryptography
By the 1960s, the computer age was beginning. People realized that:
- Classical ciphers could all be broken with enough time or message volume
- The key distribution problem was critical
- We needed something that was:
- Strong enough to resist modern computational attacks
- Practical enough to use in the real world
- Fast enough to encrypt large amounts of data
This led to the development of block ciphers - algorithms that work on fixed-size blocks of data using mathematical operations. The first widely adopted one was DES (Data Encryption Standard) in 1977.
But DES and its successors built on lessons from classical ciphers:
From Caesar Cipher: The concept of a key and keyspace
From Substitution Cipher: The idea of scrambling data to hide patterns
From Vigenère Cipher: Using multiple operations to break up patterns
From One-Time Pad: The importance of randomness and key management
What We Learned
Let’s recap what these classical ciphers teach us:
1. Small Keyspaces Are Fatal
Caesar cipher’s 25 keys can be tried in seconds. Modern ciphers use keys with 2^128 or 2^256 possibilities - impossible to brute force.
2. Patterns Are Dangerous
Substitution ciphers preserve letter frequencies. Modern ciphers use complex operations to ensure even tiny changes in input create completely different output (remember the avalanche effect from our fundamentals guide?).
3. Repetition Creates Weakness
Vigenère cipher’s repeating keyword was its downfall. Modern ciphers use techniques to ensure no patterns emerge even with repeated elements.
4. Perfect Security Is Impractical
One-time pads are unbreakable but unusable at scale. Modern cryptography accepts being "computationally secure" - not theoretically unbreakable, but practically impossible to break with current technology.
5. Key Distribution Is Critical
All classical ciphers assume Alice and Bob can somehow share a secret key. This problem wasn’t solved until the invention of public key cryptography in the 1970s (remember RSA and asymmetric encryption from our fundamentals?).
Try It Yourself
Want to play with these ciphers? Here are some encrypted messages using different techniques. Try to break them!
Message 1 (Caesar Cipher): WKH TXLFN EURZQ IRA MXPSV RYHU WKH ODCB GRJ
Message 2 (Substitution Cipher with hint: E=V): HVVRMPIB PH GSV XFIIVRXB LU GSV RMGVIMVG
Message 3 (Vigenère Cipher with keyword "CODE"): EQNVZ CQ AOJ VWAT
Click for answers
**Message 1:** \"THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG\" (shift of 3) **Message 2:** \"BITCOIN IS THE CURRENCY OF THE INTERNET\" Key was: A=Z, B=Y, C=X... (reversed alphabet) **Message 3:** \"HELLO MY OLD FRIEND\" (keyword: CODE)What’s Next
Now that we understand how classical ciphers work and why they fail, we’re ready to explore how computers revolutionized cryptography.
In the next article, we’ll look at XOR operations and Feistel networks - the fundamental building blocks that made modern encryption possible. We’ll see how simple binary operations, combined in clever ways, can create security that’s millions of times stronger than anything possible with pencil and paper.
From there, we’ll dive deep into DES - the first modern cipher that’s actually still used (in triple form) in some systems today. We’ll see how it applies the lessons from classical ciphers while adding new techniques that make it resistant to the attacks that broke every cipher that came before it.
The journey from Caesar’s simple letter shifts to the AES encryption protecting your web browsing is a fascinating story of human ingenuity, mathematical insight, and the eternal battle between code makers and code breakers.
Quick Reference
Classical Ciphers Comparison:
| Cipher | Key Space | Broken By | Main Weakness | Historical Use |
|---|---|---|---|---|
| Caesar | 25 keys | Brute force (instant) | Tiny keyspace | Julius Caesar, Roman military |
| Substitution | 26! keys (~4×10^26) | Frequency analysis | Preserves patterns | Various, including Zodiac Killer |
| Vigenère | Depends on keyword | Kasiski analysis | Repeating keyword | Civil War, European militaries |
| One-Time Pad | Infinite (if truly random) | Unbreakable | Key distribution & reuse | Cold War hotlines, spy agencies |
Key Concepts:
- Keyspace: Number of possible keys (larger is better)
- Frequency Analysis: Using letter frequency patterns to break ciphers
- Kasiski Analysis: Finding repeating patterns to break Vigenère
- Perfect Secrecy: Theoretically unbreakable (only one-time pad achieves this)
- Practical Security: Computationally infeasible to break in reasonable time