Columnar Transposition Cipher
Type a keyword and a message, and the tool writes the message in rows under the key, numbers the columns in alphabetical order and reads them off — with every grid drawn out. Decoding rebuilds the grid from the length alone, padded or not, and a second key gives you double transposition.
One column per letter, read in alphabetical order of the key; a repeated letter is numbered left to right. Digits work too (3142).
Decode with the same choices you encoded with — every character kept here is part of the grid.
The grids
Grid 1: write the message in rows under ZEBRAS
| Z | E | B | R | A | S |
|---|---|---|---|---|---|
| Order 6 | Order 3 | Order 2 | Order 4 | Order 1 | Order 5 |
| W | E | A | R | E | D |
| I | S | C | O | V | E |
| R | E | D | F | L | E |
| E | A | T | O | N | C |
| E |
Read the columns in order: EVLN · ACDT · ESEA · ROFO · DEEC · WIREE
How to Use the Columnar Transposition Cipher
- 1. Choose a mode and a keyword. Each character of the keyword heads one column. Columns are numbered in alphabetical order of their letters, repeated letters left to right; digits work too.
- 2. Decide how the last row ends. Leave it short — irregular columns — or fill it with X so every column has the same length. Sender and receiver must make the same choice.
- 3. Choose what moves. By default only letters move, in capitals, which is the classic way. Tick spaces, punctuation or lower case to move those too, and decode with the same settings.
- 4. Add a second key for double transposition, then copy the result — in five-letter groups if you like. The working shows each grid with its column numbers.
How Columnar Transposition Works
A transposition cipher keeps every letter and changes only their order. In a columnar transposition you write the message in rows as wide as the keyword, then read it out column by column — not left to right, but in the alphabetical order of the keyword's letters.
In ZEBRAS the letters in alphabetical order are A, B, E, R, S, Z, so the six columns are read in the order 6 3 2 4 1 5: the A column first. The message We are discovered. Flee at once. — 25 letters — fills four full rows and one letter of a fifth:
Grid for the keyword ZEBRAS
Z E B R A S 6 3 2 4 1 5 ----------- W E A R E D I S C O V E R E D F L E E A T O N C E
Reading the columns in number order gives EVLN, ACDT, ESEA, ROFO, DEEC and WIREE, sent as EVLNA CDTES EAROF ODEEC WIREE — the tool's sample. Filling the last row with X instead gives EVLNX ACDTX ESEAX ROFOX DEECX WIREE, with five fillers the receiver has to strike out after decoding.
Decoding: rebuilding the grid
The receiver knows the length (25) and the key (6 columns). Since 25 = 4 × 6 + 1, there are four full rows and one letter over, so the first column on the left holds five letters and the rest four. Filling the columns in number order — EVLN under A, ACDT under B, and so on, with WIREE under Z — and reading across the rows restores the message. With padding, every column is the same length and the arithmetic is simpler still.
Double transposition
Running the result through a second grid scrambles it far more thoroughly. Writing EVLNACDTESEAROFODEECWIREE under STRIPE (column order 5 6 4 2 3 1) and reading it off gives CAEEN SOIAE DRLEF WEDRE EVTOC. Decoding undoes the second grid first, then the first. When padding is on, this tool pads only the first grid, so the second is always undone from the length alone.
History
Transposition is an ancient idea — the Spartan scytale wound a strip of writing material round a rod — and John Falconer's Cryptomenysis Patefacta (1685) gives one of the earliest English explanations of a keyed columnar transposition, with the nulls that pad the last row. In the First World War the German army used a double columnar transposition that the French called Übchi; they read it regularly until their success was reported in the newspaper Le Matin, and the Germans replaced it on 18 November 1914. In the Second World War double transposition was a field cipher of the British Special Operations Executive, the American OSS, the Dutch resistance and the French Maquis, and an emergency cipher of the German army and navy.
How Secure Is Columnar Transposition?
A single transposition is weak. Its letter frequencies are exactly those of ordinary English, which tells an analyst at once that the letters were moved rather than replaced, and an analyst can guess the number of columns, cut the cipher text into columns and slide them against one another until words appear — anagramming. Irregular columns make that harder than padded ones. Double transposition was trusted in the field into the 1950s, but two messages of the same length under the same keys can be anagrammed together, and in 2013 George Lasry solved, by computer, a double transposition challenge its author had considered undecipherable. Use it to learn how transposition works, not to keep secrets.
Frequently Asked Questions
- What is a columnar transposition cipher?
- A cipher that writes the message in rows under a keyword and reads it out column by column, in the alphabetical order of the keyword's letters. Every letter of the message stays in the cipher text; only the order changes. The receiver, who knows the keyword, rebuilds the grid and reads the rows.
- How is the column order worked out from the keyword?
- Number the keyword's letters in alphabetical order. ZEBRAS gives 6 3 2 4 1 5, because A comes first and Z last. When a letter repeats, the copies are numbered from left to right, so LETTER gives 3 1 5 6 2 4. A key of digits, such as 3142, is read in numerical order.
- Should I pad the last row with X?
- Either works if both sides agree. Padding makes every column the same length, which is easier to do by hand, but the fillers have to be removed after decoding and they tell an analyst the grid's shape. Leaving the last row short — irregular columns — gives no fillers and is harder to attack.
- How do you decode a columnar transposition without the key?
- Guess the number of columns — with padding, it divides the message length — write the cipher text into columns of that length, and rearrange the columns until the rows read as words. Common letter pairs such as TH, HE and IN show which columns belong side by side. Double transposition defeats this by hand, though computers can still solve it.
- What is double transposition?
- Columnar transposition applied twice, usually with two different keywords. The output of the first grid becomes the input to the second. It is much stronger than one transposition — the Second World War resistance networks and agents of the SOE and OSS relied on it — but it is not secure against modern computer attacks.
- What is the difference between transposition and substitution?
- A substitution cipher replaces each letter with another and keeps the order; a transposition keeps the letters and changes the order. That is why a transposition leaves the letter frequencies of the plain text untouched. Historically the two were often combined, as in the ADFGVX cipher of the First World War.