Rail Fence Cipher
The simplest transposition — a zigzag that fools no one twice
Brute force · Trivial keyspace
Why This Matters
Rail Fence is a simple transposition exercise: it changes letter positions while preserving the letters themselves. Its precise origin and particular historical deployments are not established by the references here.
The zigzag pattern gives the cipher its name. This exhibit teaches that arrangement rather than attributing a specific unverified military use to it.
Write the message diagonally across a set of 'rails', then read off each rail in sequence:
3 rails, HELLOWORLD: H . . . O . . . L . E . L . W . R . D . . L . . . O . . Read rows: HOL + ELWRD + LO = HOLELWRDLO
In the version shown, the key is the number of rails and the starting direction is fixed. Trying candidate rail counts is inexpensive for ordinary short examples; whether a candidate can be identified confidently still depends on the text.
For a message of n characters, the usual rail-count-only model has fewer than n nontrivial rail counts. Trying them is a small search compared with a general substitution, though very short or unusual plaintext may be ambiguous. The widget’s rail limit is an interface choice, not a universal historical bound.
| Concept from Rail Fence Cipher | Modern Evolution |
|---|---|
| Positional rearrangement | AES ShiftRows: cyclic shift of row positions for diffusion |
| Read-by-row output | Compare position permutations in other cipher constructions |
| Tiny key space (few rails) | AES: 2¹²⁸ key possibilities — exhaustive search is computationally infeasible |
| Exhibit | 13 of 172 |
| Era | Classical Transposition |
| Trust | Broken |
| Inventor | Unknown (folk cipher) |
| Year | Origin not established |
| Key Type | Rail count (widget: 2–10) |
| Broken By | Brute force · Trivial keyspace |