> COLUMNAR TRANSPOSITION CIPHER
The idea in plain English: Write your message across a grid row by row. Then read the columns in a specific order — usually determined by a keyword. The letters come out scrambled. To decode, reverse the process: figure out the column order, fill the grid column by column, then read row by row.
Why this really exists: Columnar transposition was one of the most widely used field ciphers of World War I and World War II. It doesn't replace letters — it rearranges them. A spy could memorize a keyword (the transposition order), write the message in a grid, copy off the columns, and destroy the paper. Simple, fast, and mathematically sound enough to resist casual interception. Combined with a substitution cipher, it formed the basis of many treaty-class encryption systems used by the Allied powers.
▸ Concrete Example
Encrypt "ATTACK AT DAWN" with keyword "CAT" (keyword tells you column order: alphabetize its letters → A=1, C=2, T=3):
C A T
↓ ↓ ↓
A T T
A C K
A T
D A W
N
Keyword letters alphabetized: A=1, C=2, T=3
Read columns in order: column A (2nd), column C (1st), column T (3rd)
Ciphertext: "T C A A T A K W T D N"
To decode: know the keyword length, fill the grid column by column, read row by row.
▸ How to Decode (Step by Step)
1. Determine the number of columns from the keyword length
2. Compute the alphabetical order of the keyword letters (that's the column reading order)
3. Calculate rows = ceil(len(ciphertext) / columns)
4. Determine which columns have an extra letter (the first N % columns columns have one more row)
5. Fill columns one by one in the reading order — the first column in reading order gets the first chunk of ciphertext
6. Read the filled grid row by row → plaintext!
key = "CAT"
order = sorted(range(len(key)), key=lambda i: key[i]) # [1, 0, 2]
cols = len(key)
n = len(ciphertext)
rows = (n + cols - 1) // cols
extra = n % cols # first `extra` columns have rows+1 letters
grid = [[''] * cols for _ in range(rows)]
idx = 0
for k in order:
r = rows + (1 if k < extra else 0)
for col_block in...
(This gets involved — which is why it's a good puzzle!)
▸ Real-World Applications
- World War I: German field messages encrypted by columnar transposition — broken by Allied codebreakers at the French Cabinet Noir and British Room 40
- Double transposition: Apply columnar twice with different keys — used by the French Resistance and the US Army well into the Cold War
- Modern interleaving: Wireless protocols interleave data bits across multiple frequencies (a transposition) to survive burst interference — same idea, different medium
- Rail fence cipher: A special case of transposition where letters are written in a zigzag pattern across rows
- Scytale: The ancient Spartan ancestor — wrap text around a rod (a physical transposition)