The original Rail Fence Cipher (also called a zigzag cipher) is a form of transposition cipher that gets its name from the way in which it is encoded. In the rail fence cipher, the message is written downwards and diagonally on successive "rails" of an imaginary fence, then moving up when we reach the bottom rail. When we reach the top rail, the message is written downwards again until the whole plaintext is written out. The message is then read off in rows.
For example, if we have 3 "rails" and a message of 'WE ARE DISCOVERED. FLEE AT ONCE', the cipherer writes out:
For example, if we have 3 "rails" and a message of 'WE ARE DISCOVERED. FLEE AT ONCE', the cipherer writes out:
Then they would read off the rows, to get the ciphertext: WECRLTE ERDSOEEFEAOC AIVDEN
W . . . E . . . C . . . R . . . L . . . T . . . E
. E . R . D . S . O . E . E . F . E . A . O . C .
. . A . . . I . . . V . . . D . . . E . . . N . .
The modern version of Rail Fence Cipher is created by writing messages so that alternate letters are written on separate upper and lower lines, and are more rectangular than zig zag.
Let's use the words: SECRET SPY ACADEMY
First let's take out all the spaces: SECRETSPYACADEMY
Then decide how many "rails" (rows) you want to use. Let's use 2.
So, starting with the S in Secret, I am going to write down every second letter until I get to the end of the message.
Like this: SCESYCDM
Directly behind those letters I will write the letters I skipped.
Like this: SCESYCDMERTPAAEY
I then put the number 2 at the beginning to tell the receiver how many rails I used - and to know what to divide by.
Like this: 2SCESYCDMERTPAAEY
That is the message that the other secret agent would receive...!
2SCESYCDMERTPAAEY
To decipher an encrypted message, you will need to divide the message (number of letters total) by the number of rails.
Ask yourself this way: How many rails of ___ can I get from ___ letters? (Do not count the number! It is the key!)
The message we created has 16 letters. So let's use our formula: How many rails of 2 can I get from 16 letters? The answer is eight. So your first line should have 8 letters and your second line should have 8 letters.
Then we will write out the first 8 letters, and put the remaining 8 letters directly below them to make 2 rails (or rows).
Ask yourself this way: How many rails of ___ can I get from ___ letters? (Do not count the number! It is the key!)
The message we created has 16 letters. So let's use our formula: How many rails of 2 can I get from 16 letters? The answer is eight. So your first line should have 8 letters and your second line should have 8 letters.
Then we will write out the first 8 letters, and put the remaining 8 letters directly below them to make 2 rails (or rows).
Like this: S C E S Y C D M
---------->E R T P A A E Y
Starting at the S, you can then write out the message column by column.
Like this: SE CR ET SP YA CA DE MY
Take out the spaces and you get: SECRETSPYACADEMY;
which is easy to break into the original message: SECRET-SPY-ACADEMY
(If for some reason your message has an odd number of letters; first use your formula: How many rails of 3 can I get from 17 letters? Answer 5 (because 17 divided by 3 is 5 with 2 left over.) Use the 2 left over letters in your first 2 lines, and the remaining 5 in your last!) Answer: 6, 6, 5
(However many extra letters you have left over, will be how many lines you have to add 1 extra letter to at the end)
Another example: 4 rails, 15 letters ;(15 divided by 4 is 3 remainder 3) so each of the first three lines get an extra letter and the answer is 4, 4, 3!
(The security of the cipher can be improved by choosing more than two lines to encrypt your message with.)
which is easy to break into the original message: SECRET-SPY-ACADEMY
(If for some reason your message has an odd number of letters; first use your formula: How many rails of 3 can I get from 17 letters? Answer 5 (because 17 divided by 3 is 5 with 2 left over.) Use the 2 left over letters in your first 2 lines, and the remaining 5 in your last!) Answer: 6, 6, 5
(However many extra letters you have left over, will be how many lines you have to add 1 extra letter to at the end)
Another example: 4 rails, 15 letters ;(15 divided by 4 is 3 remainder 3) so each of the first three lines get an extra letter and the answer is 4, 4, 3!
(The security of the cipher can be improved by choosing more than two lines to encrypt your message with.)
Now you try it:
2IIFNORAAOETSUTBEKCD
(Hint: Use your formula! How many rails of 2 can I get from 19 letters? Answer 9 (18 divided by 2 is 9 with 1 remaining.) Use the 1 extra letter in line 1 and problem solved!) Answer below!
Try it again with 3 rails:
3KWDIORNLGSWOEEPE
(Hint: Use your formula! How many rails of 3 can I get from 16 letters? (16 divided by 3 is 5 with 1 remaining. So your first line gets the extra letter, for 6 letters in that line and your remaining 2 lines each have 5 letters apiece!) Answer below.
Challangers:
5STCYOALESAIOCECPDSLEARYEAPTREAMCLON
4GSSDYLOPNMSLOIEAKSDEENI
Answers:
it is fun to break a code
knowledge is power
secret spy academy is a cool place to learn
good spies need many skills
No comments:
Post a Comment