Rail fence
The rail fence cipher doesn't change any letters at all. It writes the message in a zigzag across two or more rows, the rails, and then reads each row in turn, so the right letters come out in the wrong order.
A little history
The rail fence is one of the classic transposition ciphers, where the letters are rearranged rather than replaced. The name comes from the shape of the writing: the zigzag looks like the rails of a split-rail fence. It is easy to do by hand with no equipment, which made it a popular first cipher for schoolchildren and puzzle books, and a common building block in more serious systems that combined transposition with substitution.
How it works
- Pick the number of rails, for example three.
- Write the message diagonally down and up across the rails in a zigzag.
- Read the top rail from left to right, then the next rail, and so on.
Here is the textbook example, "We are discovered, flee at once", written on three rails:
W···E···C···R···L···T···E ·E·R·D·S·O·E·E·F·E·A·O·C· ··A···I···V···D···E···N··
Reading the rails in turn gives WECRLTEERDSOEEFEAOCAIVDEN.
SPIESSSPEITo decrypt, you rebuild the zigzag: you know how many letters land on each rail, so you can cut the ciphertext into pieces and lay them back along the right rows.
How to crack it
A transposition cipher leaves every letter untouched, so letter frequencies look exactly like normal English. That gives it away straight away: if a ciphertext has plenty of E's, T's and A's in normal proportions, the letters have only been shuffled. From there, the rail fence has very few keys. Try two rails, then three, then four, and the right one jumps out as readable text.
Rail fence in Cyrune
Cyrune's rail fence uses two, three or four rails, and the zigzag can start part-way down, so the key is a rail count plus a starting step. That's only about a dozen possible zigzags. The lamps are an anagram of the answer: turn the two rotors until the windows read as a word, and use green tiles to confirm which letters belong where.
Related ciphers
- Shift + scramble ★★★☆☆
- ADFGVX cipher ★★★★☆
- Shift cipher ★☆☆☆☆