﻿ Rail Fence Cipher - A.Tools

# 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.

#### UUEncode

Tool to Encode/Decode Text with UUEncode. The PPEncode Online Tool stands as a robust solution crafted to encode and decode text using the sophisticated PPEncode algorithm.

#### XXEncode

Easily decode or encode text or code using XXEncode and XXDecode without downloading any unnecessary applications. XXEncode represents a versatile and robust solution tailored for encoding and decoding text using the XXEncode algorithm.

#### JSFuck Encode

JSFuck uses only 6 different characters "[]()!+" to write and execute code. It is an esoteric programming style based on the atomic parts of JavaScript.

#### Jother Encode

Jother is an encoding method used in JavaScript to encode strings using a concise anonymous function approach with a small set of characters. Similar to JSFuck encoding​, Jother encoding employs just 8 characters: !+()[]{}.