Rail Fence Cipher Encoder / Decoder

Free rail fence cipher encoder and decoder. Choose the number of rails, optionally keep spaces and punctuation, visualize the zigzag, and encode or decode your message.

Full original guide (expanded)

Rail Fence Cipher Encoder / Decoder

Encode or decode text with the classical rail fence cipher. Set the number of rails, decide whether to keep spaces and punctuation, and view the zigzag pattern to understand how the cipher works.

Chars processed

Rails used

Mode

Zigzag for current text and rail count (first ~40 characters shown).

How the rail fence cipher works

The message is written diagonally across several rows (rails) and then read off row-by-row.

Example: plaintext = WEAREDISCOVEREDFLEEATONCE, rails = 3

Write in zigzag:

W . . . E . . . C . . . R . . . L . . . T . . . E
. E . R . D . S . O . E . E . F . E . A . O . C .
. . A . . . I . . . V . . . D . . . E . . . N . .

Read row by row ⇒ WECRL TEERD SOEEF EAOCA IVDEN (spaces added for clarity)

Decoder notes

To decode, we rebuild the zigzag: we first mark the pattern, fill rows with ciphertext, then read in zigzag order.

FAQ

  • Does it preserve spaces? Yes, if you tick “Keep spaces/punctuation”.
  • Is it secure? No: it’s a classical teaching cipher, good for puzzles.

Audit: Complete
Formula (LaTeX) + variables + units
This section shows the formulas used by the calculator engine, plus variable definitions and units.
Formula (extracted LaTeX)
\[','\\]
','\
Formula (extracted text)
Example: plaintext = WEAREDISCOVEREDFLEEATONCE, rails = 3 Write in zigzag: W . . . E . . . C . . . R . . . L . . . T . . . E . E . R . D . S . O . E . E . F . E . A . O . C . . . A . . . I . . . V . . . D . . . E . . . N . . Read row by row ⇒ WECRL TEERD SOEEF EAOCA IVDEN (spaces added for clarity)
Variables and units
  • No variables provided in audit spec.
Sources (authoritative):
Changelog
Version: 0.1.0-draft
Last code update: 2026-01-19
0.1.0-draft · 2026-01-19
  • Initial audit spec draft generated from HTML extraction (review required).
  • Verify formulas match the calculator engine and convert any text-only formulas to LaTeX.
  • Confirm sources are authoritative and relevant to the calculator methodology.
Verified by Ugo Candido on 2026-01-19
Profile · LinkedIn
Formulas

(Formulas preserved from original page content, if present.)

Version 0.1.0-draft
Citations

Add authoritative sources relevant to this calculator (standards bodies, manuals, official docs).

Changelog
  • 0.1.0-draft — 2026-01-19: Initial draft (review required).