Skip to main content

Cryptography & Ciphers

Rail Fence Cipher Encoder

Encode text with the rail fence zigzag cipher. Choose rails and offset while preserving spaces and punctuation.

Tool workspace

Your input stays in this browser.

Add the required input to continue.

Needs input

You can run the tool again after any change.

Options

Number of zigzag rows. Use a whole number from 2 to the input length.

Steps into the zigzag before the first character. Start with 0.

Your result appears here

Encode text with the rail fence zigzag cipher. Choose rails and offset while preserving spaces and punctuation.

This tool runs open-source code from CyberChef by GCHQ (Apache License 2.0). See open-source credits.

The encoder writes characters down and up the rails, then reads each row from top to bottom.

The result contains the same character units in a different order.

  • Build a transposition clue for a classroom lesson, puzzle hunt, or escape room.

Sources: A Book on Classical Cryptography: railfence

Rearrange WEAREDISCOVEREDFLEEATONCE

Input: WEAREDISCOVEREDFLEEATONCE

Settings: Rails 3 and Offset 0.

Result: WECRLTEERDSOEEFEAOCAIVDEN

The three rows contain WECRLTE, ERDSOEEFEAOC, and AIVDEN.

Set rails and offset without discarding spaces

  1. Enter the message.
  2. Set Rails and Offset. Zero offset starts at the top rail.
  3. Save both settings with the ciphertext.
  • Spaces and punctuation occupy rail positions.
  • UTF-16 code units can split an emoji.
  • The cipher preserves letter frequencies and does not protect secrets.