You are on page 1of 6

The Rail Fence

Cipher
What is Rail Fence Cipher ?
• Called a "zigzag cipher" because we make a rectangle box and write plain text into
it in a zigzag form.

• Works by writing your message on alternate lines across the page, and then
reading off each line in turn.
How Rail Fence Cipher works?
• The plain-text is written downwards and diagonally on successive rails
of an imaginary fence.(key = no. of rows)

• 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.
Example
• Plaintext - “THIS IS A SECRET MESSAGE”.
• Key = 4
• To encode this message we will first write over four lines (the “rails of
the fence”) as follows:

• Ciphertext - TATGHSSEMAEIIERESSCS
Activity
• Encrypt the below plaintexts.
1. See you tomorrow. (key- 3)
2. Meet me after the class.-(key 4)
3. I don’t like sweets. (key- 2)

• Decrypt the ciphertexts.


1. ELTEDECUEINECOPRCCXMSE .-(key 4)
2. TGSEOINTCLCIIEHOA-TTNLU .-(key 5)

You might also like