Rail Fence

The Rail Fence cipher is a transposition cipher where the plaintext is written diagonally on a number of 'rails' then read off horizontally.

Rails
2

Explanation

The Rail Fence cipher is a transposition cipher that works by writing the plaintext in a zigzag pattern across a number of 'rails' or 'fences,'' and then reading off the ciphertext from the pattern formed by the rails.

We first write the message in a zigzag pattern across 3 'rails.'' Then we read off the ciphertext by concatenating the characters from each rail. So, 'HELLO WORLD' is encrypted to 'HOLL ELWRLOL' using the Rail Fence cipher with 3 rails.

To decrypt a Rail Fence ciphertext, the process is reversed. Write the ciphertext in a zigzag pattern across the rails. Read off the plaintext from the pattern formed by the rails.

The Rail Fence cipher is relatively easy to implement and understand, but it's not very secure against modern cryptanalysis techniques. It's often used as a teaching tool rather than for serious encryption.

Facts

It was used by both Confederate and Union forces during the American Civil War.