Search for a tool
Rail Fence (Zig-Zag) Cipher

Tools to decode/encode Rail Fence, a cipher using zig-zag writing, automatic decryption with brute-force mode.

Results

Rail Fence (Zig-Zag) Cipher -

Tag(s) : Transposition Cipher

Share
Share
dCode and more

dCode is free and its tools are a valuable help in games, maths, geocaching, puzzles and problems to solve every day!
A suggestion ? a feedback ? a bug ? an idea ? Write to dCode!


Please, check our dCode Discord community for help requests!
NB: for encrypted messages, test our automatic cipher identifier!


Feedback and suggestions are welcome so that dCode offers the best 'Rail Fence (Zig-Zag) Cipher' tool for free! Thank you!

Rail Fence (Zig-Zag) Cipher

Rail Fence Decoder

 



Parameters and Options






Rail-Fence Encoder

 








Answers to Questions (FAQ)

What is Rail Fence cipher? (Definition)

The Rail Fence cipher (also called zigzag) is a transposition cipher consisting in writing a text in zig-zag and reading it in a straight line.

How to encrypt using Rail Fence cipher?

Rail Fence Encryption uses an integer for the number of levels of the zigzag.

The encoded message is written in zig-zag (like a rail fence/sawtooth) along a path with N levels/floors.

Example: Encrypt DCODEZIGZAG with N=3 is writing

D---E---Z--
-C-D-Z-G-A-
--O---I---G

The cipher message is read by rows.

Example: The encrypted message is DEZCDZGAOIG

How to decrypt Rail Fence cipher?

RailFence decryption requires knowing the number of levels N.

Example: Decrypt the message DEZCDZGAOIG with N=3

Write the expected zigzag form and complete it by lines, before reading as zig zag

Example:

X---X---X--
-X-X-X-X-X-
--X---X---X
then
D---E---Z--
-C-D-Z-G-A-
--O---I---G

Example: The original plain text is DCODEZIGZAG.

How to recognize Rail Fence ciphertext? (Identification)

A message encoded by Rail-Fence has an index of coincidence equal to that of the language of the original text.

Frequency analysis reveals usual occurrences of common letters similar to a plain text.

All references to zig-zag, sawtooth, up and down, path/track/route, etc. are clues.

Anything in the shape of bumps can also be a clue: camel, speed bump, etc.

The word rail can be the target of puns about trains, railroads, railway, cocaine/coke, etc.

How to decipher Rail Fence without the number of levels?

Rail Fence can be cracked by testing all levels from 2 to N. Use the Brute-force attack button.

What are the variants of the Rail Fence cipher?

There are several variations:

— The fence may begin with a peak or a hollow (up or down).

Example: A---E
-B-D-
--C--
(↘↗ hollow)

Example: --C--
-B-D-
A---E
(↗↘ peak)

— The first letter is not necessarily the base of the peak or hollow, the zig zag can start in the middle (equivalent to add spaces at the beginning)

Example: ----D-
-A-C-E
--B---
(One shift)

— It is possible to allow spaces and punctuation, which shifts the characters.

What happens if the key is greater than or equal to the length of the text?

If the value of the number of levels is greater than or equal to the size of the text, then the text undergoes no encryption (no change).

What is the difference between Rail Fence and ZigZag?

None, Rail Fence is the original word, ZigZag is the mnemonic term.

When Rail-Fence was invented?

Rail-Fence is a basic transposition, no date or creator is recognized.

Source code

dCode retains ownership of the "Rail Fence (Zig-Zag) Cipher" source code. Except explicit open source licence (indicated Creative Commons / free), the "Rail Fence (Zig-Zag) Cipher" algorithm, the applet or snippet (converter, solver, encryption / decryption, encoding / decoding, ciphering / deciphering, translator), or the "Rail Fence (Zig-Zag) Cipher" functions (calculate, convert, solve, decrypt / encrypt, decipher / cipher, decode / encode, translate) written in any informatic language (Python, Java, PHP, C#, Javascript, Matlab, etc.) and all data download, script, or API access for "Rail Fence (Zig-Zag) Cipher" are not public, same for offline use on PC, mobile, tablet, iPhone or Android app!
Reminder : dCode is free to use.

Cite dCode

The copy-paste of the page "Rail Fence (Zig-Zag) Cipher" or any of its results, is allowed as long as you cite dCode!
Cite as source (bibliography):
Rail Fence (Zig-Zag) Cipher on dCode.fr [online website], retrieved on 2023-02-08, https://www.dcode.fr/rail-fence-cipher

Need Help ?

Please, check our dCode Discord community for help requests!
NB: for encrypted messages, test our automatic cipher identifier!

Questions / Comments

Feedback and suggestions are welcome so that dCode offers the best 'Rail Fence (Zig-Zag) Cipher' tool for free! Thank you!


https://www.dcode.fr/rail-fence-cipher
© 2023 dCode — The ultimate 'toolkit' to solve every games / riddles / geocaching / CTF.
 
Feedback