Rail Fence Cipher
- It refers to a very basic form of transposition cipher.
- It rearranges the order of the letters of the message (plaintext) in a quick and convenient way.
Encryption
- The plaintext (original message) is written downwards diagonally on successive rails (fence or rows). When you reach the bottom you move upwards and when you reach the top you move downwards).
- Read the message as a sequence of rows.
Example
Plaintext = "nothing as it seems"
rails (key / depth) = 2
n | t | i | g | s | t | e | m | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
o
|
h
|
n
|
a
|
i
|
s
|
e
|
s
|
- To encrypt, read it as a sequence of rows (write down the characters of 1st row and then characters of 2nd row)
Cipher-text = “ntigstemohnaises”
Decryption
- Create a number of columns = number of characters in cipher-text, in our example, it is 16
- Have a number of rows = rail fence or depth, in our example, it is 2
- Write first letter n in 1st column, then leave 2nd column, write the 2nd character in the 3rd column, then leave 4th column and so on.
- Read it in the zigzag form
Cipher-text = “ntigstemohnaises”
n | t | i | g | s | t | e | m | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
o
|
h
|
n
|
a
|
i
|
s
|
e
|
s
|
Plaintext = "nothing as it seems"
Watch the video to actually view the steps of encryption and decryption