Toolzy

Rail Fence Cipher

Encrypt or decrypt text with the classic zigzag Rail Fence transposition cipher.

Input
Output

The Rail Fence cipher writes your message in a zigzag across a chosen number of rails, then reads it off row by row to scramble the letter order. Adjust the rail count and switch between encrypt and decrypt — everything runs locally in your browser.

How to use

  1. Set the number of rails (zigzag rows).
  2. Choose Encrypt or Decrypt.
  3. Type your text and copy the transformed result.

Frequently asked questions

Is the Rail Fence cipher secure?
No, it's a simple classical transposition cipher easily broken by trying all rail counts; it's useful for learning cryptography basics or puzzles, not real security.
What happens with 2 rails?
With 2 rails, the cipher simply splits the message into every-other-letter and interleaves them; more rails create a more zigzagged pattern.
Do spaces and punctuation get scrambled too?
Yes, every character including spaces and punctuation is placed on the zigzag, so decoding restores the exact original text.

Related tools