Lesson №04 5th century BC 18 min
Transposition: scytale, rail fence, columns
You can leave every letter untouched and still make a message unreadable: just shuffle them. We wind a strip round a Spartan rod, write in a zigzag and reorder columns by a keyword.
In this lesson
- how transposition differs from substitution
- how the scytale works and why its key is the thickness of a rod
- how to encrypt with a rail fence and with keyword columns
- how letter counts give a transposition away, and how it is broken
Sparta, the end of the fifth century BC. The admiral Lysander is at war far across the sea, off the coast of Asia Minor. One day a messenger arrives and hands him a narrow leather strip covered in letters. It can’t be read: the letters are jumbled and no words show. Lysander takes out his rod, the twin of one kept in Sparta by the magistrates called ephors, winds the strip round it turn against turn, and lines of writing appear along the rod. The order is short: come home at once.
Plutarch tells this story in his life of Lysander. The rod was called a scytale (say SKIT-a-lee), and it is one of the earliest descriptions of a device for secret writing. The striking thing is that no letter was changed. Every letter on the strip is the very letter the ephors wrote. Only their order was different.
Two great families of ciphers
In the first lessons we changed letters: Caesar shifted the alphabet, the substitution cipher put another letter in place of each one. These are substitution ciphers. An A turns into something else, but it stays where it was.
Transposition ciphers do the opposite. Every letter remains itself, but moves to a different place. CODE might become DECO or OCED. The key is not a table of replacements but the rule by which the letters are shuffled. Knowing the rule, you can put them back.
Here is the simplest example, the one every child invents: write the word backwards. “Meet me” becomes “em teeM”. That is a transposition too, only a very weak one: the rule is the same for everybody and there is no key at all. A real transposition cipher hides its rule in a key that only two people share.
You can tell a transposition from a substitution without knowing the key. Count the letters of the cipher text. If E, T, A and O are the most common, just as in ordinary English, the letters were not changed, only shuffled. A substitution keeps the counts too, but hands them to other letters: the most common one might be X.
The scytale: a key you can hold
The scytale is very simple. Take a rod and wind a narrow strip around it in a spiral, turn against turn, with no gaps. Then write the message along the rod, line after line, turning the rod after each line. Unwind the strip, and the letters scatter along it. Neighbours on the strip come from different lines.
To read it you need a rod of the same thickness. On a thick rod one turn of the strip holds more letters, on a thin one fewer. If the thickness is wrong, the letters of a line slant away and mix with the next one. If it is right, the lines fall into place. So the key of the scytale is the thickness of the rod, or more exactly, how many letters fit into one turn.
Look closely at the strip. Each turn is a few letters in a row, and from each turn exactly one faces you. The line you see on the rod is every fourth (or fifth, or third) letter of the strip. That is the whole secret: the scytale reads the strip in steps, and the thickness sets the step.
It also shows the weakness. There aren’t many sensible thicknesses: a rod you can hold carries between two and about ten letters per turn. An enemy who seized the strip could wind it round a cone, a rod that slowly gets thicker, and slide it along until the letters line up into words. Even without a cone a pencil will do: copy out every second letter, every third, every fourth… It is the same brute force that broke the Caesar cipher.
Historians argue about whether the scytale really was a cipher. The Spartans may have valued it mostly as proof of origin: an order that lined up on “your” rod surely came from the ephors. But the idea of transposition shows in it perfectly.
A captured courier carried this strip, but no rod. Where is the gold?
The key is the number of letters per turn. Try them in order, from two upwards, and watch the line at the bottom: when do words appear?
The strip has 24 letters. It sits best on a rod where 24 divides evenly by the letters per turn: 2, 3, 4, 6 or 8.
With six letters per turn the rod shows six lines of four: THEG / OLDI / SUND / ERTH / EOLD / WELL. In turn: “The gold is under the old well”. The answer is under the old well.
Notice how quickly it fell: seven tries and the key is yours. The whole strength of the scytale rests on the enemy not guessing there is a cipher, or not having time to try the rods.
The rail fence: writing in a zigzag
The scytale needs a rod. But the same idea, reading a text in steps, works on paper. The best-known paper version is the rail fence, named after the old fences of wooden rails laid in a zigzag.
Draw a few horizontal lines, the “rails”. Write the message in a zigzag: the first letter on the top rail, the second on the next, the third on the one below, and when you reach the bottom, turn back up. The letters lie in a wave. Then copy them out rail by rail: everything on the top rail, left to right, then the second rail, and so on to the bottom. That string is the cipher text.
Watch the colours. The cipher text is coloured pieces laid end to end: the red rail, the blue one, the green one. To decrypt, the receiver needs to know only the number of rails. She draws the same empty zigzag, counts how many cells fall on each rail, and deals the cipher letters back: the first ones onto the top rail, the next onto the second. Then she reads the wave from left to right.
The key of a rail fence is a single small number. With two rails the cipher merely splits the letters into odd and even places. With twenty rails a short note stretches into an almost straight diagonal and hardly gets shuffled at all. There are about ten sensible keys, and you can try them all in a minute. So the rail fence is more a game and a classroom exercise than a cipher for serious mail. But it shows the main point well: a transposition is a route, the path along which letters are written and then read.
Your contact left a note written as a rail fence. He didn’t say how many rails: “You’ll work it out.” What is today’s password?
TPRIOSAODHSDYSWITTEASSL
Try the number of rails: two, three, four… The rail fence tool makes this easy: its brute-force panel shows every option at once, ranked by how much each looks like English.
The message starts with the word “today”.
With four rails a zigzag of 23 letters puts 4 letters on the top rail (T, P, R, I), 7 on the second, 8 on the third and 4 on the bottom. Deal the cipher text out in pieces of those lengths and read the wave: “Today’s password is thistle”. The answer is thistle.
The trick is in the lengths of the pieces. Knowing the number of rails and the length of the message, the receiver works them out in advance, and that is all she needs.
Columns and a keyword
For the rail fence and the scytale the key is a number, and there are few numbers. The next step suggests itself: make the key not a number but an order. That is columnar transposition, the workhorse of military code clerks in the nineteenth and twentieth centuries.
Agree on a keyword, say CASTLE. Write its letters in a row: they head the columns. Under them write the message row by row, one letter per cell. Now number the columns by the alphabetical order of the key’s letters: A comes first, so its column is 1; then C is 2, E is 3, L is 4, S is 5 and T is 6. Copy out the columns in that order, each from top to bottom.
The scytale is a special case of this cipher: its columns are read in plain order, left to right, with no keyword. The keyword adds a shuffle of the columns. With five different letters in the key there are 120 orders; with seven, already 5040. The word itself doesn’t matter, only the order it sets: CASTLE and, say, BAEFDC give exactly the same cipher text.
The receiver, knowing the key, rebuilds the grid: works out how many rows there will be, deals the cipher text into columns in key order, and reads the rows. If the last row is short, some columns are one letter shorter, and that too follows from the length of the message.
A single transposition is fairly easy to break (see below), so it was often done twice, with two different keys. After a double transposition, letters that were neighbours in the plain text are scattered all over the cipher text. Double transposition was used in earnest in both world wars. And the German ADFGX cipher of 1918 joined transposition to substitution: first each letter became a pair of letters from a square, then the pairs were shuffled by columns. You can try it in the Polybius square tool.
How a transposition is broken
Imagine you work in a black chamber and an intercepted message lands on your desk. The first question is what you are looking at, substitution or transposition. A simple count of letters answers it. In a transposition the letters are those of the plain text, so the counts look like ordinary language: lots of E, T, A, O, N, few J, Q, Z. If that is the picture, the letters were only shuffled, and what you are looking for is the route.
The second step is to guess the shape of the grid. The length of the message suggests how many columns there may be: 24 letters fit 4 columns of 6, or 6 of 4, and so on. If the last row was short there are more options, but not many more.
The third step is the elegant one. Cut the cipher text into pieces, one per column, and write each on its own strip of paper. Then slide the strips next to each other and look at the pairs of letters that form across the rows. If you see TH, HE, IN, ER, the strips are probably neighbours. If you see QZ or JX, they certainly aren’t. Pair by pair, strip by strip, the columns fall into the right order. This is called anagramming: hunting for the shuffle that makes the letters into words again.
A computer does the same, only faster. For a short key it simply tries every column order and scores each result by how many familiar letter groups it contains. That is what the “If the key is unknown” panel of the columnar transposition tool does: for keys of up to seven letters it checks 5912 orders and almost always puts the right one first.
A transposition doesn’t change the letters, it changes their places. So the letter counts of the cipher text are those of ordinary language: that is its signature. The key of a transposition is the route along which the letters are written and read.
In an intercepted message the most common letters are E, T, A and O, just as in English. What does that tell you?
Substitution changes the letters, so the counts pass to other letters. Transposition doesn’t touch the letters at all, so the counts stay exactly as in the plain text. It is the first question a cryptanalyst asks.
Why do the keys CASTLE and BAEFDC give the same columnar transposition?
The keyword is there only to number the columns. In CASTLE and in BAEFDC the second letter comes first in the alphabet, the first letter second, and so on: the order 2-1-5-6-4-3 is the same. So breaking it means trying orders, not words.
What to take with you
- Ciphers fall into two great families: substitution changes the letters, transposition changes their order.
- The scytale reads a strip in steps; its key is the thickness of the rod, the number of letters per turn. The rail fence writes in a zigzag; its key is the number of rails.
- Columnar transposition makes the key an order of columns, set by a keyword. Five columns give 120 orders, seven give 5040.
- Letter counts give a transposition away: they look like ordinary language. It is broken by finding the route that makes neighbouring letters into familiar pairs again.
Next, a different world. Letters can be not only hidden but also sent: down a wire, over the radio, by a flashing lamp. For that you need a code, not a cipher. Next: Morse code →
Tools for this lesson
Everything from the lesson, working: paste your own text.
- Rail fence cipher The rail fence: text zigzags across rails. See each letter land, and brute-force the rail count.
- Columnar transposition Keyword columnar transposition: the grid, the column order, encryption and decryption.
- Polybius square and tap code The Polybius square: letters to digit pairs and back, the prisoners’ tap code and ADFGX.
- Frequency analysis Letter and bigram frequencies and the index of coincidence, against English or Russian.