HomeForumRiddle ToolsWallpapersLinks
Rail Fence Cipher
 
A Rail Fence Cipher is where the text is arranged in a wave-like pattern. Start by first reading down by the number of set lines (called rails), then up, then down again etc. Take the example "SAMPLE TEXT HERE" and arrange in waves as shown in the diagram below. The spaces are replaced with an * simply to illustrate that the spaces are not removed.

s   l   e   h   
 a p e t x * e e
  m   *   t   r 

To compile the cipher text you would then read across the rows, keeping the spaces in.

SLEH
APETX EE
M TR

Then the lines are combined; the individual lines are ignored and the string of letters is separated with the new position of the spaces to get SLEHAPETX EEM TR - this is the cipher text.

Occasionally the cipher text is 'offset', this is where the text to be encoded does not start on the top rail, but starts on a lower rail. It is then entered and read in exactly the same way as before. N.B the offset must be equal to or less than the number of rails.

The example below shows our sample text offset by 2:

  m   *   t   r 
 a p e t x * e e
s   l   e   h  
The cipher text in this case would be: M TRAPETX EESLEH.
 

Encode / Decode
Rails: The number of rows, which determines the height of the waves.

Offset: Instead of starting on the top rail and working down, you can start on any rail and move up or down depending on where you place the offset. Should be less than (rail * 2 - 1).


Your message:

Show the rails

This is your encoded or decoded text. If there are two spaces in a row or if there is a space at the beginning or end, those spaces will not show up. Be careful when copying encrypted text and make sure that it will decrypt to the message properly.

Result: