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".

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. The message is then read off in rows.

Here is an example of the message WE ARE DISCOVERED. FLEE AT ONCE encrypted with three rails

  1. W . . . E . . . C . . . R . . . L . . . T . . . E
  2. . E . R . D . S . O . E . E . F . E . A . O . C .
  3. . . 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 messages with the rail fence cipher, and the second can be used to crack messages encrypted with the rail fence cipher by brute force - it simply outputs a decoded message for different numbers of "rails."

Here is the encoder:

PLANETCALC, Rail fence cipher encoder

Rail fence cipher encoder

Encrypted message
WRIVDLANEAEDSOEE.FE TOC CR E E

And here is the brute force decoder:

PLANETCALC, Rail fence cipher decoder

Rail fence cipher decoder

The file is very large. Browser slowdown may occur during loading and creation.

Decode table

RailsMessage
2W.RFIEV DTLOACN E ACERD SEO EEE
3WE ARE DISCOVERED. FLEE AT ONCE
4WA.RFNREE AIETEODVSC ODE ECEL
5WDD TSLRAOOECENIEE .AVEFCERE
6WDE.CE FDLRASE C ONIEETRE OEAV
7WVEOE E EADRLEETC RO.DAINSFC E
8WVEOFOC RCEEADRLEE EE T.DAINS
9WILAOFOC RCEEEAVRDNDE EE T.SE
10WILEDEFOC RCEESAAVRDNEO. EE T

URL copied to clipboard
PLANETCALC, Rail fence cipher

Comments