Rail Fence Cipher
Encode and decode messages using the Rail Fence Cipher.
About Rail Fence Cipher
The Rail Fence Cipher is a form of transposition cipher. It derives its name from the manner in which it is encoded. The message is written in a zigzag pattern on an imaginary fence, then read off line by line.
How it Works
To encode a message using the Rail Fence Cipher, you write the message diagonally down and up across the rails on the fence, then read the message off in rows.
For example, using 3 rails, the message "WE ARE DISCOVERED FLEE AT ONCE" is written as:
W . . . E . . . C . . . R . . . L . . . T . . . E . E . R . D . S . O . E . E . F . E . A . O . C . . . A . . . I . . . V . . . D . . . E . . . N . .
The encoded message is "WECRLTEERDSOEEFEAOCAIVDEN".
To decode the message, you reverse the process by writing the characters in a zigzag pattern and then reading them off line by line.