Get reference code
Appearance
Sample
Rail fence cipher

Rail fence cipher

This article contains two calculators, first can be used to encode message with the rail fence cipher, second can be used to crack message encoded with the rail fence cipher by brute force. Decoded simply outputs decoded message for different number of "rails".
Timur2017-06-01 09:42:46

The rail fence cipher (also called a zigzag cipher) is a form of transposition cipher. A transposition cipher involves the rearranging of the letters in the plain text to encrypt the message.

In the rail fence cipher, the plain text is written downwards and diagonally on successive "rails" of an imaginary fence, then moving up when we reach the bottom rail. When we reach the top rail, the message is written downwards again until the whole plaintext is written out. The message is then read off in rows.

Here is the example of message WE ARE DISCOVERED. FLEE AT ONCE encrypted with 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 . .

Then we read it off in rows we will get
WECRLTEERDSOEEFEAOCAIVDEN

The rail fence cipher is a very old encryption scheme, pre-dating the Middle Ages. It was used as a field cipher by both sides in the US Civil War.

The number of rails used to break up the message serves as the cryptographic key. The rail fence cipher is not very strong, the number of practical keys (the number of rails) is small enough that a cryptanalyst can try them all by hand. Thus, these days you can meet it in games, geocaches, riddles or puzzles. Below you can find two calculators, first can be used to encrypt message with the rail fence cipher, second can be used to crack message encrypted with the rail fence cipher by brute force - it simply outputs decoded message for different number of "rails".

Here is the encoder:

Rail fence cipher encoderCreative Commons Attribution/Share-Alike License 3.0 (Unported)
Encrypted message: 

And here is brute force decoder:

Rail fence cipher decoderCreative Commons Attribution/Share-Alike License 3.0 (Unported)
Decode table:

Request a calculator
View all calculators
(514 calculators in total. )

Comments