Zigzag transposition
Rail Fence cipher
Encrypt or decrypt text with a defined top-first zigzag and an exact rail count.
01 / Workspace
Transpose text
Mode
Encryption writes down and up the rails, then reads each rail from top to bottom.
Use a whole number from 1 to 5,000. Encryption and decryption must use the same count.
0 / 5,000 code points
Case, punctuation, spaces, tabs, line feeds, emoji, and non-Latin text all participate in the path.
Ready to encrypt.
02 / Result
Result
0 code points
The result contains the same Unicode code points in a different order. No padding is added or removed.
Rail path preview
Up to 72 positionsEach line is one rail. Empty positions use a middle dot; spaces, tabs, and line feeds use visible marks.
Run a valid conversion to see the plaintext path.
03 / Convention
How this version works
- The first code point starts on the top rail. The path moves down by one rail at each position.
- At the bottom rail the path reverses upward; at the top rail it reverses downward.
- Encryption joins the rails from top to bottom. Decryption rebuilds that path, fills the rails from top to bottom, and follows the path to recover the text.
- No offset, alternate starting direction, padding, filtering, case conversion, or Unicode normalization is applied.
Limits and security
- Input is limited to 5,000 Unicode code points and 10,000 UTF-16 code units. Rails are limited to 1 through 5,000, and the preview is limited to 72 positions and 12 rails.
- One rail, or a rail count equal to or greater than the input length, returns the input unchanged. This is valid and reported clearly.
- Each Unicode code point is one path position. Combining marks, variation selectors, and joined emoji sequences can be separated from neighboring code points by the transposition.
- Spaces, punctuation, and line feeds are preserved and moved like other code points. Browser text controls normalize pasted CR and CRLF line endings to LF.
- Rail Fence is a classical cipher for educational use and is unsuitable for sensitive data.