Rail fence cipher
Encrypt and decrypt the classic zigzag transposition with a configurable rail count.
Related tools
Rail fence cipher
The rail fence is the transposition cipher everyone meets first: write the message diagonally, bouncing between the top and bottom of an imaginary fence, then read it off row by row. WE ARE DISCOVERED FLEE AT ONCE on three rails becomes WECRLTEERDSOEEFEAOCAIVDEN — every letter is still there, only the order changed. This tool runs it both ways: encrypt scrambles, decrypt rebuilds the zigzag and reads the message back out.
The rail count is the key — two rails barely shuffle, twenty rails on a short message change nothing at all (the zigzag never folds), and the sweet spot in classic puzzles is three to five. The offset option starts the zigzag partway through its cycle, a common variant in geocaching and CTF challenges that breaks naive solvers. By default whitespace is stripped before ciphering, the classical presentation; keep spaces and punctuation switches to a pure transposition of every character, which makes the round trip lossless for full sentences.
Everything operates on Unicode code points, so č, ő and even emoji ride the fence intact rather than being split into surrogate halves. The tally shows how many characters travelled and on how many rails.
Like every classical cipher this is a puzzle and a teaching tool, not protection — with at most a few dozen sensible keys, brute force is instant. For actual secrecy use the AES-based encrypt text tool. Everything runs locally in your browser; your message never leaves your device.