0% found this document useful (0 votes)
190 views14 pages

Railfence Cipher

Uploaded by

Amir
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
190 views14 pages

Railfence Cipher

Uploaded by

Amir
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 14

Rail fence 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 various types of transposition cipher are: –

1. Rail fence technique


2. Simple columnar transposition technique (SCTT)
3. Book cipher/ Running key cipher
Rail fence
• The rail fence technique is an example of a transposition cipher that
involves rearranging the letters of a message by writing it in a zigzag
pattern on a number of “rails.”
• The number of rails is usually equal to the key, and the message is
written out in a pattern that follows the rails, going up and down as it
moves from left to right
Explanation
• The rail fence cipher (also
called a zigzag cipher) is a
form of transposition cipher.
It derives its name from the
way in which it is encoded
Encryption
• In a transposition cipher, the order of the alphabets is re-arranged to
obtain the cipher-text.
• In the rail fence cipher, the plain-text is written downwards and
diagonally on successive rails of an imaginary fence.
• When we reach the bottom rail, we traverse upwards moving
diagonally, after reaching the top rail, the direction is changed again.
Thus the alphabets of the message are written in a zig-zag manner.
• After each alphabet has been written, the individual rows are
combined to obtain the cipher-text.
Rail fence encryption

• 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

• And the cipher text became: "dnetleedheswlxftaax"


Rail Fence Cipher Decryption
• As we have studied earlier, the number of columns in rail fence cipher
remains equal to the length of plain-text which we took. And the key
remains the same as in encryption to the number of rails.

• 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

You might also like