{"uid":"cap_a0uiVqgsZbL0mARra7Ob6","slug":"rail-fence-zigzag-cipher-encode-decode-2038b374","name":"Rail Fence (Zigzag) Cipher Encode/Decode","description":"Rail fence (zigzag) transposition cipher encode or decode with 2 to 20 rails; letters and digits only by default.","url":"https://text-ciphers.x402tookit.com/rail-fence?utm_source=zero.xyz","method":"GET","headers":{},"bodySchema":{"type":"object","$schema":"https://json-schema.org/draft/2020-12/schema","required":["input"],"properties":{"input":{"type":"object","required":["type","method"],"properties":{"type":{"type":"string","const":"http"},"method":{"enum":["GET"],"type":"string"},"queryParams":{"type":"object","required":["text","rails"],"properties":{"raw":{"type":"string","description":"true to keep spaces and punctuation as characters on the fence (default: letters and digits only, upper-cased)"},"mode":{"type":"string","description":"encode (default) or decode"},"text":{"type":"string","description":"Plain or cipher text (up to 1000 characters)"},"rails":{"type":"integer","description":"Number of rails, 2 to 20"}}}},"additionalProperties":false},"output":{"type":"object","required":["type"],"properties":{"type":{"type":"string"},"example":{"type":"object","properties":{"asOf":{"type":["null","string"]},"mode":{"type":["null","string"]},"input":{"type":["null","string"]},"rails":{"type":["null","number"]},"output":{"type":["null","string"]},"secure":{"type":["boolean","null"]},"source":{"type":["null","string"]},"reasons":{"type":["array","null"],"items":{"type":"string"}},"summary":{"type":["null","string"]},"verdict":{"type":["null","string"]},"degraded":{"type":["boolean","null"]},"prepared":{"type":["null","string"]},"disclaimer":{"type":["null","string"]},"notChecked":{"type":["array","null"],"items":{"type":"string"}}}}}}}},"responseSchema":null,"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.02","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.02/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.02","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.02","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_DeMDNeFszial3Y1AJrkyg","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.02","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Encodes or decodes text using the rail fence (zigzag) transposition cipher with a configurable number of rails (2–20).","exampleAgentPrompt":"Encode the message 'HELLO WORLD' using the rail fence cipher with 3 rails.","exampleUseCases":[{"title":"CTF puzzle rail fence decode","prompt":"I found this ciphertext 'HOLELWRD' in a CTF challenge that I think uses a rail fence cipher — can you decode it using 3 rails?"},{"title":"Teaching transposition cipher concepts","prompt":"Encode the phrase 'WEAREDISCOVEREDFLEEATONCE' with a rail fence zigzag cipher using 4 rails so I can show my students how it works."},{"title":"Puzzle maker encoding messages","prompt":"Use the rail fence cipher to encode 'MEETMEATMIDNIGHT' with 5 rails — I want to include it as a hidden message in a puzzle I'm designing."}],"resultDescription":"Returns a JSON object containing the encoded or decoded output text, the input text, the number of rails used, the mode (encode/decode), and metadata such as source, summary, and any disclaimer about the cipher's security.","failureModes":["Missing required 'text' or 'rails' parameter returns an error","Rails value outside 2–20 range may return a validation error","Text exceeding 1000 characters may be rejected","Invalid mode value (not 'encode' or 'decode') may cause unexpected behavior","Non-alphanumeric characters silently stripped unless 'raw=true' is set"],"whenToPreferThis":"Choose this endpoint when you need to encode or decode text specifically using the rail fence (zigzag) transposition cipher, especially for CTF challenges, cryptography education, or puzzle-making. It supports configurable rails (2–20) and optionally preserves spaces and punctuation. Prefer it over Caesar or Vigenere endpoints when the cipher type is specifically a columnar/rail transposition rather than a substitution cipher.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-10-21T07:20:24.144Z","isFirstParty":false,"canonicalSlug":"rail-fence-zigzag-cipher-encode-decode-2038b374"}