Rail fence cipher decoder. This online calculator helps to decode message encrypted using rail fence cipher by listing variants of decoded text 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 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
Then we read it off in rows we will get
WECRLTEERDSOEEFEAOCAIVDEN
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:
And here is brute force decoder:
The rail fence cipher (sometimes called zigzag cipher) is a transposition cipher that jumbles up the order of the letters of a message using a basic algorithm.
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, let’s consider the plaintext “This is a secret message”.
To encode this message we will first write over two lines (the “rails of the fence”) as follows:
Note that all white spaces have been removed from the plain text.
Note that all white spaces have been removed from the plain text.
The ciphertext is then read off by writing the top row first, followed by the bottom row:
Your Challenge
For this challenge, you will have to write two python programs, one to encrypt a message (plaintext to ciphertext), one to decrypt an encoded message (ciphertext to plaintext). To help you with this challenge we have created the flowcharts of both the encoder and the decoder algorithms.
Rail Fence Cipher – Encoder
Python Code
Rail Fence Cipher – Decoder
Python Code
Break the code!
Use your python script to decipher the following encoded message:
CYTGAHITEROWIIGROVNCDSRPORPYSHATFRTNOSLIGOE
Extension Task
More complex Rail Fence Ciphers have more “rails”. For instance instead of writing the code over two lines (“rails”) you can write over three or four or more lines. The number of lines used in a Rail Fence Cipher is called the key.
Key = 3
A Rail Fence Cipher with 3 “rails” (Key = 3)
Key = 4
Investigate how you could adapt both your encoding and decoding python programmes to enable to encrypt and decrypt messages with different keys.
Other challenges you may enjoy...
Tagged with: cryptography, encryption