Railfence Cipher
Railfence Cipher
Attia Agha
Transposition algorithm
• Transposition Cipher is a cryptographic algorithm where the order of
alphabets in the plaintext is rearranged to form a cipher text.
• Cryptanalysts observed a significant improvement in crypto security
when transposition technique is performed. They also noted that re-
encrypting the cipher text using same transposition cipher creates
better security.
Difference b/w substitution and transposition
technique
Transposition techniques
• The plaintext we have i.e "defend the east wall" having a key size
or the size of the row is 3, we get the encryption method below
• That at the end of the message we have inserted two "X"s. These
are called nulls and act as placeholders. We do this to make the
text fit into the rail so that there is the same number of letters on
the top row as well as on the bottom row. Otherwise, it is not
necessary, it makes the decryption process a bit easier if the text
has this format.
Encryption
• Hence, the Rail Fence matrix can be constructed likely. Once we have got
the matrix we can find-out the places where plain texts should be placed
using the same way as we doe in the encryption method of moving
diagonally up and down alternatively to form text.
• Then, we fill the cipher-text accordingly to row-wise. After filling the text,
we traverse the matrix in the zig-zag form to get the original text or the
plain text
Decryption
• If we get the cipher text "TEKOOHRACIRMNREATANFTETYTGHH", it
will be encrypted with a key size of 4.
• We start by placing the "T" in the first square. You then dash the
diagonal down places until you get back to the top line, and place the
"E" here. Continuing to fill the rows you get the pattern below,
First
stage
Decryption
• As we have a key size of 4 and the length of the message is 28 so we
make like this and continues this till all the text does not fit into it.
Second
stage
Now, we read them as diagonally from top to bottom
then bottom to top and we get the plain text or the
original text i.e. "THEY ARE ATTACKING FROM THE
NORTH".
Third
stage
Fourth
stage
Thanks