Rail Fence Cipher Encoder + Decoder
The Rail Fence cipher writes plaintext in a zigzag pattern across N "rails", then reads off row-by-row. Classic transposition cipher — easy to break by brute force (just try 2-10 rails) but a fun puzzle cipher.
How to use the Rail Fence Cipher Encoder + Decoder
Pick encrypt/decrypt, set number of rails. The zigzag pattern visualization shows how the cipher works.
How the rail fence zigzag works
The rail fence is a transposition cipher: it does not change the letters, it rearranges their order. You write the plaintext diagonally down and up across a fixed number of rows — the rails — in a zigzag, then read the letters off one full row at a time to get the ciphertext. With three rails, the message bounces down to the bottom rail, back up to the top, and so on, distributing letters across the rows by position.
Because the only secret is the number of rails, it is trivial to break: an attacker just tries each rail count from two upward until readable text appears. That makes it useless for real security but a popular puzzle, escape-room, and CTF cipher, and a clear first example when teaching the difference between transposition and substitution. This tool encrypts, decrypts, and draws the zigzag so you can see the pattern.
Common use cases
- Puzzles and escape rooms — encode a clue that solvers can crack with a little effort.
- CTF challenges — create or solve a classic transposition step in a capture-the-flag.
- Teaching cryptography — demonstrate transposition as distinct from substitution ciphers.
- Decoding a known cipher — recover plaintext when you know or can guess the rail count.
- Visualizing the method — watch the zigzag fill to understand how the letters scatter.