Cyber Trainer Crypto Primer
Crypto Primer · Chapter 03

Classical ciphers

For most of history, cryptography meant pen, paper and clever tricks. These ciphers are easy to break today, but they introduce the two basic techniques every modern cipher still uses: transposition (rearranging) and substitution (replacing).

A short timeline

The scytale (transposition)

A strip of leather or parchment was wound around a rod (the scytale) and the message written along its length. Unwound, the strip shows a jumble of letters. Only someone with a rod of the same diameter can line them up again. The rod's diameter is the key.

The letters themselves don't change. Only their positions do. That's pure transposition, and it's why the letter frequencies of the ciphertext match normal English, which gives the method away.

Wrap the strip

Message written along the rod (each row is one turn around it):

Unwound strip (ciphertext, read down the columns):

The Caesar cipher (substitution)

Each letter is replaced by the letter a fixed number of places further along the alphabet. Caesar reportedly used a shift of 3, so A→D, B→E and so on, wrapping around at Z. ROT13 is the same idea with a shift of 13, which makes encryption and decryption identical.

The key space is just 25 useful shifts, so an attacker can simply try them all.

Caesar wheel

Ciphertext

The pigpen cipher

The pigpen (or Freemason's) cipher replaces each letter with a symbol based on its position in two grids and two Xs. The shape of the "pen" around the letter, and whether it has a dot, becomes the symbol. It looks mysterious, but it's just a simple substitution with symbols instead of letters, so frequency analysis breaks it just as easily.

Write in pigpen

The rail fence cipher

Another transposition cipher. You write the message in a zig-zag across a number of "rails", then read each rail left to right. The number of rails is the key. It was reportedly used during the American Civil War.

Zig-zag

Ciphertext (read rail by rail)

Breaking substitution: frequency analysis

In English, E makes up about 12.7% of letters, followed by T, A, O, I and N. A monoalphabetic cipher (Caesar, Atbash, pigpen, any one-to-one swap) changes the letters but keeps their frequencies. Count the symbols in the ciphertext, line up the peaks with English, and the key falls out. Al-Kindi described this over 1,100 years ago.

Crack a Caesar cipher

■ letter counts in the ciphertext, after your shift   ■ normal English frequencies

Vigenère: polyalphabetic substitution

Vigenère uses a keyword to pick a different Caesar shift for each letter. With key LEMON, the first letter shifts by 11 (L), the second by 4 (E), and so on, repeating. The same plaintext letter turns into different ciphertext letters, which flattens the frequency peaks.

It held out for about 300 years. The weakness is the repeating key. Kasiski noticed that repeated chunks of ciphertext reveal the key length. Once you know the length, the message splits into several separate Caesar ciphers, and each one falls to frequency analysis. If you make the key random and as long as the message, you've reinvented the one-time pad.

Vigenère encoder
What history teaches us Each classical cipher failed because it leaked structure: letter frequencies, positions, or a repeating key. Modern ciphers are designed so the ciphertext is statistically indistinguishable from random, which is where confusion, diffusion and large key spaces from Chapter 02 come in.

Knowledge check