By Debmedia Technologies LLP · Kolkata, India · Updated
What Is It and When Do You Need It?
The rail fence cipher scrambles a message by changing the order of its letters, not the letters themselves. The text is laid out in a wave pattern across a few rails and then read row by row. It is a favourite in puzzles because it is easy to do on paper.
Choose the number of rails, and the tool encrypts or decrypts, with a picture of the fence.
How to Use This Tool
- Type or paste your text.
- Choose the number of rails.
- Choose encrypt or decrypt.
- Press Run and read the result and the fence picture.
How the Calculation Works
The rail number of each character follows 0, 1, 2 … top, then back down … 1, 0 and so on. Encryption collects the characters of rail 0, then rail 1 and so on. Decryption works out how many characters belong to each rail, fills the rails in order and reads the zigzag again.
Worked Example
With 3 rails, WEAREDISCOVEREDFLEEATONCE becomes WECRLTEERDSOEEFEAOCAIVDEN.
Common Uses
- Puzzles and escape rooms.
- Teaching transposition.
- Geocaching.
- Studying classic ciphers.
Tips and Common Mistakes
- Try 2, 3 and 4 rails when you do not know the key.
- More rails make the text look more scrambled.
- Spaces count as characters.
Related Tools
Next, you may need the Caesar cipher, Polybius square, Atbash cipher, Vigenère cipher.
Everything runs in your browser. Nothing you type is uploaded, stored or sent to any outside service.
Frequently Asked Questions
Disclaimer: results are calculated in your browser from the numbers you enter. Check important results before you rely on them for money, health, safety or legal decisions.