Network Tutorial 1 Submit2
Network Tutorial 1 Submit2
Caesar Cipher
The earliest known, and the simplest, use of a substitution cipher was by Julius Caesar. The
Caesar cipher involves replacing each letter of the alphabet with another letter. The following
example shows the replacement of each letter by three places further down the alphabet. For
example,
Note that the alphabet is wrapped around, so that the letter following Z is A. We can define the
transformation by listing all possibilities, as follows:
plain: a b c d e f g h i j k l m n o p q r s t u v w x y z
cipher: D E F G H I J K L M N O P Q R S T U V W X Y Z A B C
Rather than just shifting the alphabet like in Caesar cipher, we can shuffle (jumble) the letters
arbitrarily. Each plaintext letter maps to a different random cipher text letter. Hence, key is 26
letters long.
plain: a b c d e f g h I j k l m n o p q r s t u v w x y z
cipher: D K V Q F I B J W P E S C X H T M Y A U O L R G Z N
The 'key' for a playfair cipher is generally a word, for the sake of example we will choose
'monarchy'. This is then used to generate a 'key square', e.g.
M O N A R
C H Y B D
E F G I K
L P Q S T
U V W X Z
Any sequence of 25 letters can be used as a key, so long as all letters are in it and there are no
repeats. Note that there is no 'j', it is combined with 'i'. We now apply the encryption rules to
encrypt the plaintext.
1. Remove any punctuation or characters that are not present in the key square (this may
mean spelling out numbers, punctuation etc.).
2. Identify any double letters in the plaintext and replace the second occurrence with an 'x'
e.g. 'hammer' -> 'hamxer'.
3. If the plaintext has an odd number of characters, append an 'x' to the end to make it
even.
4. Break the plaintext into pairs of letters, e.g. 'hamxer' -> 'ha mx er'
5. The algorithm now works on each of the letter pairs.
6. Locate the letters in the key square, (the examples given are using the key square
above)
If the letters are in different rows and columns, replace the pair with the letters on the same row
respectively but at the other pair of corners of the rectangle defined by the original pair. The
order is important – the first encrypted letter of the pair is the one that lies on the same row as
the first plaintext letter. 'ha' -> 'bo', 'es' -> 'il'
1. If the letters appear on the same row of the table, replace them with the letters to their
immediate right respectively (wrapping around to the left side of the row if a letter in the
original pair was on the right side of the row). 'ma' -> 'or', 'lp' -> 'pq'
2. If the letters appear on the same column of the table, replace them with the letters
immediately below respectively (wrapping around to the top side of the column if a letter
in the original pair was on the bottom side of the column). 'rk' -> 'dt', 'pv' -> 'vo'
Example of playfair encryption using the same key square
plaintext: wearediscoveredsaveyourselfx
ciphertext: ugrmkcsxhmufmkbtoxgcmvatluiv
Encrypt the following using Playfair Cipher (using the same key square) :
: TH EC ARKE YI SL OC AT ED UN DE RT HE DO OR MA TT
Ans : PD LE RM EF GB TP WH SR KC XM MK DZ CF HR NM OR RR
: WE WI LX LM EX ET TO MO RX RO WA TA LA MA ND AP UT RA JA YA
Ans : GU XG SU UC IU KL PR NO AZ MO NX SR SM OR RY OS ZL MR SB BN
: TH ET RE AS UR EI SL OC AT ED UN DE RT HE CO CO NU TX TR EX EX
Ans : PD KL MK BX ZM FK TP MH RS KC WM CK TZ CF HM HM MW SZ ZD IU IU