Redefence Cipher Encoder/Decoder
Choose a mode, set the rails and key, then enter your text.
Result
How it is calculated
The text is written in a zig-zag over the chosen number of rails (at least 2): rail 1, 2, 3, 2, 1, 2, 3 … Every character counts, including spaces, punctuation and lower case; nothing is removed or changed in case. To encode, each rail is read left to right and the rails are joined in the order given by the key: the first key number names the rail read first, and so on. To decode, the text is cut into rail lengths in that same key order and put back along the zig-zag. The key must list every rail number from 1 to N exactly once, written as 231, 2 3 1 or 2,3,1; if it is empty, the natural order 1, 2, 3 … is used. Wrong key length, repeated or out-of-range numbers give no result. It is a classical puzzle cipher and gives no real security.
Worked example
Encode WEAREDISCOVERED with 3 rails and key 231. Rail 1: W E C R. Rail 2: E R D S O E E. Rail 3: A I V D. Reading rail 2, then rail 3, then rail 1 gives ERDSOEE + AIVD + WECR = ERDSOEEAIVDWECR. Switching to Decode with the same rails and key returns WEAREDISCOVERED.
Common mistakes
- Decoding with a different number of rails or a different key than was used to encode; both must match exactly, or the output is scrambled.
- Reading the key as "rail 1 goes to position 2". Here the key lists the rail to read first, second and so on, so 231 starts with rail 2.
- Writing a key that skips or repeats a rail number (such as 221 or 21 for 3 rails), which the tool rejects.
- Expecting spaces to be dropped; they are treated like letters, so a message with spaces gives an output with spaces in other places.
- Pasting ciphertext with a stray trailing space or line break; the extra character shifts the rail lengths and breaks decoding.
About this calculator
The Redefence cipher is a keyed variant of the classic rail-fence cipher. Plaintext letters are written in a zig-zag pattern down and up across N rails (rows), exactly as in a normal rail fence — but instead of reading the rows off in top-to-bottom order, a numeric key determines the order the rails are read in, adding an extra layer of scrambling beyond the basic zig-zag.
Like other rail-fence variants, it's a transposition cipher — it rearranges letters rather than substituting them — and offers only modest security by modern standards. It shows up mainly in cryptography education, puzzle hunts, and CTF (capture-the-flag) challenges as a step up from the plain rail fence, illustrating how adding a key to a simple transposition scheme increases the keyspace an attacker has to search.
Was this helpful?
You can pick up to 3 reactions.
Popular calculators
Loan Calculator
Monthly payment, total interest and full amortization schedule.
Percentage Calculator
Percent change, percent of, and ratio calculations.
Discount Calculator
Calculate final price, savings, and discount amount.
BMI Calculator
Body mass index from height and weight (metric or imperial).
Age Calculator
Compute your exact age in years, months and days from a birth date.
Compound Interest Calculator
Calculate the final amount and interest earned with compounding.
All Calculators
- Loan Calculator
- Profit Calculator
- Discount Calculator
- BMI Calculator
- Percentage Calculator
- Ideal Weight Calculator
- Age Calculator
- Pregnancy Due Date Calculator
- Compound Interest Calculator
- BMR Calculator (Basal Metabolic Rate)
- Tip Calculator
- Fuel Cost Calculator
- Date Difference Calculator
- Sleep Cycle Calculator
- Daily Water Intake Calculator
- Simple Interest Calculator
- Heart Rate Zones Calculator
- Running Pace Calculator
- Pet Age Calculator
- Calories Burned Calculator
- Macro Calculator
- TDEE Calculator (Total Daily Energy Expenditure)
- Waist-to-Hip Ratio Calculator
- Honor Roll Calculator
- One Rep Max (1RM) Calculator
- Ovulation Calculator
- Electricity Cost Calculator
- Unit Price Calculator
- Savings Goal Calculator
- Break-Even Point Calculator
- Paint Calculator
- Course Grade Average Calculator
- Business Days Calculator
- Time Duration Calculator
- Fuel Economy Calculator
- Temperature Converter
- Tile Calculator
- Aspect Ratio Calculator
- Roman Numeral Converter
- Goal Weight Timeline Calculator
- Salary Converter (Hourly to Annual)
- Credit Card Validator (Luhn)
- Body Surface Area (BSA) Calculator
- Feels-Like Temperature Calculator
- Ohm’s Law Calculator
- PPI (Pixel Density) Calculator
- Molar Mass Calculator
- Zodiac Sign Calculator (Western + Chinese)
- IBAN Validator
- Shoe Size Converter
- Country Info & Dialing Code Lookup
- Time Zone Difference (World Clock)
- CAGR (Compound Annual Growth Rate) Calculator
- Rule of 72 Calculator
- Blood Alcohol Content (BAC) Calculator
- Lean Body Mass (LBM) Calculator
- Pythagorean Theorem Calculator
- Speed Converter
- Download Time Calculator
- Date Calculator (Add/Subtract)
No calculators found
Comments (1)
A wrong key does not produce an error as long as it is a valid permutation, only scrambled text, so a puzzle solver can simply try them all: three rails have six possible keys, four rails have 24 and five rails have 120. Counting spaces correctly matters as well. Which puzzle or hunt is this from, and did the plaintext come out readable?