Rail Fence Cipher

Cipher Type
Number Of Rails

Rail Fence Cipher is a classical type of transposition cipher. It derives its name from the manner in which encryption is performed, in analogy to a fence built with horizontal rails.

The Rail Fence Cipher is a very simple, easy to crack cipher. It is a transposition cipher that follows a simple rule for mixing up the characters in the plaintext to form the ciphertext. The railfence cipher offers essentially no communication security, and it will be shown that it can be easily broken even by hand.

Although weak on its own, it can be combined with other ciphers, such as a substitution cipher, the combination of which is more difficult to break than either cipher on it's own.

In the Rail Fence Cipher, the plaintext is written downwards diagonally on successive "rails" of an imaginary fence, then moving up when the bottom rail is reached, down again when the top rail is reached, and so on until the whole plaintext is written out. The ciphertext is then read off in rows.


Encryption

In the Rail Fence Cipher, the plaintext is written downwards diagonally on successive "rails" of an imaginary fence, then moving up when the bottom rail is reached, down again when the top rail is reached, and so on until the whole plaintext is written out. The ciphertext is then read off in rows.

The Rail Fence Cipher places the letters in a zigzag pattern before reading them again, from top to bottom, right to left, ignoring the zigzag.

Example:

Let's imagine that we are encoding Hello World! on 3 rails. we draw out our three rails and place the lettres in the zigzag pattern like this:

H - - - o - - - r - - -
- e - l -   - o - l - !
- - l - - - w - - - d -

When this is read top to bottom, left to right, we get Horel ol!lwd

Decryption

Decoding is a bit harder. We can re-railfence the encoded string to find out how many characters there are per rail. From that, we can divide up the first encoded string into chunks according to their rail, and place them on a series of rails, to then read them according to the zigzag pattern.

Example:

First, we need to figure out how many characters there are per rail. We do this by re-encoding the already railfenced string and counting the characters per rail.

H - - - l - - - ! - - -        3 characters
- o - e -   - l - l - d        6 characterst
- - r - - - o - - - w -        3 characters

Now we can divide the first string according to that 3, 6, 6 pattern, to get Hor, el lod!, lwd. Placing these onto a set of rails like these:

| - - - | - - - | - - -
- | - | - | - | - | - |
- - | - - - | - - - | -

We can are back to the original set of rails used to encode the message, and we are able to read the original message if we follow the zigzag pattern.


Tip:

In the "Cipher Type" of our cipher online, there are 2 values: "W-Type" is also called "Zigzag Cipher", it  refer to the Rail Fence Cipher as described above. The another value "Classic" refer to a different type of cipher described by Fletcher Pratt in Secret and Urgent. It is "written by ruling a sheet of paper in vertical columns, with a letter at the head of each column. A dot is made for each letter of the message in the proper column, reading from top to bottom of the sheet. The letters at the head of the columns are then cut off, the ruling erased and the message of dots sent along to the recipient, who, knowing the width of the columns and the arrangement of the letters at the top, reconstitutes the diagram and reads what it has to say." This is equivalent to using an un-keyed columnar transposition cipher.

Morse code is a system of communication that uses two different signal durations, called dots and dashes, to encode text characters. It was invented by Samuel F.B. Morse in the 1830s and became widely used for telegraphy, the transmission of messages over long distances by electric wires.

Morse Code

Morse code is a system of communication that uses two different signal durations, called dots and dashes, to encode text characters. It was invented by Samuel F.B. Morse in the 1830s and became widely used for telegraphy, the transmission of messages over long distances by electric wires.
SHA encryption is a term that refers to a family of cryptographic hash functions that are used to verify the integrity and authenticity of data. A hash function is a mathematical function that takes an input and produces a fixed-length output, called a hash or a digest, that is unique for each input. SHA encryption can be used to generate digital signatures, checksums, passwords and other security applications.

SHA Encrypt

SHA encryption is a term that refers to a family of cryptographic hash functions that are used to verify the integrity and authenticity of data. A hash function is a mathematical function that takes an input and produces a fixed-length output, called a hash or a digest, that is unique for each input. SHA encryption can be used to generate digital signatures, checksums, passwords and other security applications.
​PBKDF2 Encryption is a specific type of Password-Based Key Derivation Function Encryption (PBKDF Encryption) that uses a pseudorandom function, such as hash-based message authentication code (HMAC), to generate a derived key from a password or a passphrase

PBKDF2 Encrypt

​PBKDF2 Encryption is a specific type of Password-Based Key Derivation Function Encryption (PBKDF Encryption) that uses a pseudorandom function, such as hash-based message authentication code (HMAC), to generate a derived key from a password or a passphrase
Symmetric Encrypt & Decrypt Online Tool is a web online tool that allows you to encrypt and decrypt text using symmetric encryption algorithms such as AES, Triple DES and DES. Symmetric encryption is widely used for data protection, authentication and digital signatures.

Symmetric Encrypt & Decrypt

Symmetric Encrypt & Decrypt Online Tool is a web online tool that allows you to encrypt and decrypt text using symmetric encryption algorithms such as AES, Triple DES and DES. Symmetric encryption is widely used for data protection, authentication and digital signatures.