3 WEAREDISCOVEREDFLEEATONCE
WECRLTEERDSOEEFEAOCAIVDEN
A classic Rail Fence example with three rails.
Encrypt and decrypt text with the Rail Fence cipher using a configurable number of rails. Learn how zigzag transposition works and experiment with different rail counts.
3 WEAREDISCOVEREDFLEEATONCE
WECRLTEERDSOEEFEAOCAIVDEN
A classic Rail Fence example with three rails.
3 WECRLTEERDSOEEFEAOCAIVDEN
WEAREDISCOVEREDFLEEATONCE
The same rail count is required to restore the plaintext.
4 DEFENDTHEEASTWALLOFTHECASTLE
DNETLHSEEDHESWLFTEATEFATAOLC
Changing the rail count changes the zigzag pattern and the resulting ciphertext.
3 MEET AT NOON
M NETA ONETO
Spaces are preserved and participate in the zigzag transposition pattern like other characters.
The Rail Fence cipher is a classical transposition cipher that rearranges the positions of characters without changing the characters themselves. The message is written in a zigzag pattern across a chosen number of rails and then read row by row to produce the ciphertext.
For example, with three rails, the text moves diagonally down and up across the rows. Increasing the number of rails creates a different pattern and therefore a different ciphertext.
To decrypt a message, the same rail count must be used. The zigzag structure is reconstructed first, then the characters are placed back into their original positions.
With three rails, the message is written diagonally down and up before the rows are read from left to right:
W . . . E . . . C . E . R . D . S . . . A . . . I . .
The dots show empty positions in the zigzag pattern. The ciphertext is created by reading the first rail, then the second rail, then the third rail.
Unlike substitution ciphers such as Caesar or Vigenere, Rail Fence does not replace letters with other letters. It only changes their order.
Because the original characters remain unchanged, frequency analysis is less useful, but the cipher is still easy to break by testing possible rail counts. Today Rail Fence is mainly used for education, puzzles, and introducing the concept of transposition ciphers.
Classic letter-shift cipher with custom shift values.
Classic digraph substitution cipher with keyword matrix encryption.
Classical reciprocal cipher based on a keyword.
Vigenere-style classical cipher that uses a numeric key.
Keyword-based polyalphabetic encryption and decryption.
XOR-based Vernam encryption with Base64 output.