The Rail Fence Cipher, or often called the ZigZag, is a form of transposition cipher.  A transposition cipher rearranges the letters of a message following a system. The reason it is called a rail fence is because letters of a message are rearranged by lines that can look like rails of a fence.  There can be any number of rails used, 2 and above.

For instance, if the message, ‘Treasure the Adventure’ wanted to be encoded by a 3 rail fence cipher, the message would be written on a diagonal, of 3 rails, and turned back up again.  It would follow this zigzagging movement until all letters are used on the imagined fence rails.

T       S       T       D       T       X
  R   A   U   E   H   A   V   N   U   E  
    E       R       E       E       R    

 

The letters of a line (or rail) are then written in this new transposed way:  X’s are placed to complete the cycle of the rail.  So Treasure the Adventure would become:

TSTDTXRAUEHAVNUEEREER

As you can see, the letters of the first line are followed by the second and third, transposing, and concealing the original message.

The Rail Fence is not considered a secure type of encryption. Often times trial and error on the amount of rails used can break the system.

It still offers puzzling fun though.2

In the Armchair Treasure Hunts book: Quests for Hidden Treasure, an exciting book containing many codes and puzzles to have fun with, it is used on page 36.

An image of a ‘rail fence’ is seen very faintly in the background of the gibberish looking message, offering a clue to the system used to decode it.  Can you decode it?

rail fence cipher
Cipher in Armchair Treasure Hunts: Quests for Hidden Treasure by Jenny Kile

While the above is encoded in a straightforward manner, there are ways to make the Rail Fence Cipher more tricky to decode.

The person encrypting the message could encode spaces, or instead of using an X at the end to fulfill spots on the rail, he could use a more common letter to throw off those trying to decode the curious string.

For instance, let’s include spaces while encoding ‘Treasure the Adventure’ and use an T instead to complete the cycle. We’ll keep with a 3 rail system.  Letters + Characters are added together for a total of 23.

T       S                       E       R    
  R   A   U   E   T   E   A   V   N   U   E  
    E       R       H       D       T       T

 

The coded text is now written as follows:

TSER   RAUETEAVNUE  ERHDTT

It has taken on a whole new appearance, creating a small stumbling block, for someone trying to discover what is being said!

 

Best of luck with all that you seek!   ATRDRLSRUEAVUEWYESTEETXAAHNX  !   (how many rails does that secret message use?)

 

 

 

One Comment

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.