Rail Fence Cipher

Rail Fence cipher is transposition cipher.In this cipher plaintext is written as diagonally downwards or you can say wave sort of pattern called "Rails".For example take a plaintext "I LIKE THIS BLOG" and arrange it in a wave pattern

I         E            S          G
  L    K   T     I     B    O
     I           H           L

So the encrypted code for this plaintext will be IESGLKTIBOIHT.To make it more easy to decrypt we can indicate spaces as * in the rails.

I         K          H        B
  *    I     E    T    I    *   L     G
    L           *          S         O

So now the ciphertext will be IKHB IETI LGL SO

Now the question is how do we know that how many letters are taken in downward direction and upward direction?

Well for that we have something called:

Rails-The number of rows which determine the height of the waves

Offset-Instead of starting on the top rail and moving down you can start on any rail and move up and down depending on where you placed offset.

For example considering the above plaintext suppose my value of rails is 3 which is same as above and value of offset is 1.Now the wave arrangement will be

          I             T           *           G
I     L     K     *    H    S    B    O
   *             E           I           L

Offset=1 means that now the wave pattern will start from one next position to the original one ie shift one position downwards.

Note-The value of offset should be less then (rails*2-1)

So now you can see the difference in the arrangement and the ciphertext which is IT GILK HSBO EIL.

Thus you can change value of rails and offset to get differnet pattern and ciphertext everytime.

Some of the good sites i found on internet for encryption and decryption of railfence ciphers are Braingle and  rumkin.com,

See some more Ciphers on this blog Vignere Cipher , Masonic Cipher


    

Comments

Popular posts from this blog

Tricky Questions or Puzzles in C

Program to uncompress a string ie a2b3c4 to aabbbcccc

Number series arrangement puzzles