Rail Fence Cipher

Encrypt and decrypt messages using the Rail Fence (zigzag) transposition cipher — choose the number of rails and get the result with working shown.

What Does This Tool Do?

The Rail Fence cipher writes text in a zigzag pattern across a set number of rails, then reads off row by row. A transposition cipher — letters are rearranged rather than substituted.

Key Features

🚂
Zigzag Pattern
Writes diagonally across chosen number of rails.
🔄
Encrypt & Decrypt
Both directions with the same rail count.
📐
Working Shown
Understand the rail pattern.
📋
Copy Result
One-click copy.

How to Use

  1. Enter the message to encrypt or decrypt.
  2. Set the number of rails (default 3).
  3. Click Encrypt or Decrypt.

Frequently Asked Questions

How does the Rail Fence cipher work?
Write the message diagonally across N rails in a zigzag. Then read off each rail left-to-right. Example with 3 rails: "HELLO" → H on rail 0, E on rail 1, L on rail 2, L on rail 1, O on rail 0.
Is it a substitution or transposition cipher?
Transposition — the letters stay the same but their positions are rearranged. No letter is replaced by another.
How do I decrypt?
Enter the ciphertext, set the same number of rails, and click Decrypt. The tool reconstructs the zigzag positions and reads off the original order.