Toolstia / Rail fence cipher

Rail fence cipher

Write a message in a zigzag across a number of rails and read it off row by row, or reverse the process to decrypt. A small grid shows how the letters sit on the rails.

The rail fence cipher writes the message in a zigzag across the rails and reads it off row by row. Spaces and punctuation are part of the message, so they move too. In the picture a dot stands for a space. With as many rails as characters, or more, nothing changes.

How it works

  1. Choose encrypt or decrypt and the number of rails.
  2. Type your text.
  3. Copy the result and check the grid.

How it works

Letters are written diagonally down and up across the rails. The cipher text is the rows joined together from top to bottom.

Example

WEAREDISCOVEREDFLEEATONCE on 3 rails becomes WECRLTEERDSOEEFEAOCAIVDEN.

Spaces

Spaces and punctuation are part of the message and move like letters. In the grid a dot stands for a space.

Security

There are only a few possible keys, so it is easy to crack. It is a classic puzzle and teaching cipher.

Questions

How many rails should I use?

Any number from 2 to 50. More rails than characters changes nothing. Everything happens in your browser, and nothing you enter is sent anywhere.

Can I decrypt without knowing the rails?

Try different rail counts until the text makes sense.

Why is the grid missing?

It appears only for encryption of texts up to 48 characters.