Rail fence cipher |
|
One common type of cipher is called a "transposition" cipher. You don't replace any letters of your message, but you do rearrange them in a specific way to make your message hard to read unless you know the rule to how it was mixed up. One transposition cipher that was used during the U.S. Civil War was called the "Railroad Cipher." It is actually not the hardest code to track, but it slowed down enemies enough in trying to decipher it that it served it's purpose. Lincoln was known to use ciphers in sending orders to his generals |
|
Abe Lincoln and the Rail Fence Cipher |
|
The railfence cipher is an easy to apply transposition cipher that jumbles up the order of the letters of a message in a quick convenient way. It also has the security of a key to make it a little bit harder to break. The Rail Fence cipher works by writing your message on alternate lines across the page, and then reading off each line in turn. For example, the plaintext "defend the east wall" is written as shown below, with all spaces removed. |
The simplest Rail Fence Cipher, where each letter is written in a zigzag pattern across the page. |
To encrypt a message using the Rail Fence Cipher, you have to write your message in zigzag lines across the page, and then read off each row. Firstly, you need to have a key, which for this cipher is the number of rows you are going to have. You then start writing the letters of the plaintext diagonally down to the right until you reach the number of rows specified by the key. You then bounce back up diagonally until you hit the first row again. This continues until the end of the plaintext. For the plaintext we used above, "defend the east wall", with a key of 3, we get the encryption process shown below. |
|
The Rail Fence Cipher with a key of 3. Notice the nulls added at the end of the message to make it the right length. |
|
Note that at the end of the message we have inserted two "X"s. These are called nulls, and act as placeholders. We do this to make the message fit neatly in to the grid (so that there are the same number of letters on the top row, as on the bottom row. Although not necessary, it makes the decryption process a lot easier if the message has this layout. The ciphertext is read off row by row to get DNETL EEDHE SWLXF TAAX |
|
Created with the Personal Edition of HelpNDoc: Easily create CHM Help documents


