Substitution Technique 03
Substitution Technique 03
Techniques
Playfair cipher
Playfair square and Wheatstone-Playfair cipher.
Manual symmetric encryption technique.
The first literal diagram substitution cipher.
Invented in 1854 by Charles Wheatstone.
The name of Lord Playfair for promoting its use.
Breaks plaintext into digraphs, inserting an "X" between each pair.
Replaces letters in the same row, column, or rectangle if they appear in the same
row.
Replaces letters in the same row, column, or rectangle if they form a rectangle.
Playfair cipher
Multiple letter encryption cipher.
Diagrams.
Uses a 5x5 matrix of letters for encryption.
Place keyword letters in 5x5 grid, row by row.
Fill remaining spaces with unused alphabet letters.
Ex : Monarchy
M O N A R
C H Y B D
E F G I/J K
L P Q S T
U V W X Z
Rules for encryption using Playfair cipher
1. Diagrams
2. Repeating letters – Add filler letter
3. Same column | | Wrap around
4. Same row | | Wrap around
5. Rectangle | | Swap
M O N A R
C H Y B D
E F G I/J K
L P Q S T
U V W X Z
Example :
Plaintext : attack
Diagram : at ta ck
Plaintext : academy
Diagram : ac ad em yx
Plaintext : balloon
Diagram : ba ll oo n
Diagram : ba lx lo on M O N A R
C H Y B D
E F G I/J K
L P Q S T
U V W X Z
Understanding the rule
Example : attack
Diagrams : at ta ck
at ta ck
RS SR DE
M O N A R
Plaintext : attack
Ciphertext : RSSRDE C H Y B D
E F G I/J K
L P Q S T
U V W X Z
Understanding the rule
Example 2 : mosque
mo sq ue
ON TS ML
Plaintext :mosque M O N A R
Ciphertext :ONTSML
C H Y B D
E F G I/J K
L P Q S T
U V W X Z
Question
1. Encrypt the message “Exam day is next month” using Playfair technique with the keyword “Academy”
Ex am da yx is ne xt mo nt hr
GE CA EC GU NP SG ZS HT OS FT
A C D E M
Plaintext : Exam day is next month
Ciphertext : GECAECGUNPSGZSHTOSFT Y B F G H
I/J K L N O
P Q R S T
U V W X Z
Hill Cipher
Example : Encrypt “pay more money” using hill cipher with key.
0 1 2 3 4 5 6 7 8 9 10 11 12
17 17 5
Key = 21 18 21 A B C D E F G H I J K L M
2 2 19
13 14 15 16 17 18 19 20 21 22 23 24 25
N O P Q R S T U V W X Y Z
Key = 3*3 matrix
Encrypting : pay
17 17 5
( C1 C2 C3 )= (15 0 24) 21 18 21 mod 26
2 2 19
Encryption :
Decryption :
17 17 5 17 17 17 17 5 17 17
Adj K = 21 18 21 21 18 Adj K = 21 18 21 21 18
2 2 19 2 2 2 2 19 2 2
17 17 5 17 17 17 17 5 17 17
21 18 21 21 18 21 18 21 21 18
K-1 = 1 * Adj K
Det K
14 25 7
K-1 = 1
* 7 1 8 mod 26
23 23-1 * 23 = 1 mod 26 9 * 23 = 25 mod 26
6 0 1
1 * 23 = 23 mod 26 10 * 23 = 22 mod 26
2 * 23 = 20 mod 26 11 * 23 = 19 mod 26
3 * 23 = 17 mod 26 12 * 23 = 16 mod 26
*
4 * 23 = 14 mod 26 13 * 23 = 13 mod 26
5 * 23 = 11 mod 26 14 * 23 = 10 mod 26
6 * 23 = 8 mod 26 15 * 23 = 7 mod 26
7 * 23 = 5 mod 26 16 * 23 = 4 mod 26
8 * 23 = 2 mod 26 17 * 23 = 1 mod 26
238 425 119
K-1 = 119 17 136 mod 26
102 0 17
4 9 15
K-1 = 15 17 6
24 0 17
Decrypting “RRLMWBKASPDH” using Hill Cipher with key
17 17 5
21 18 21 = Key
2 2 19
Solution :
P = C K-1 mod 26
R R L M W B K A S P D H
17 17 11 12 22 1 10 0 18 15 3 7
Decrypting : RRL
4 9 15
P1P2P3 = (R R L ) 15 17 6 mod 26 Decryption
24 0 17
4 9 15
C1C2C3 = 17 17 14 15 17 6 mod 26
24 0 17
Encryption process :
Ci = ( Pi + Ki mod m) mod 26
Decryption process :
Pi = ( Ci – Ki mod m ) mod 26
Vigenére Cipher
Key : deceptivedeceptivedeceptive
Plaintext : wearediscoveredsaveyourself
Key 3 4 2 4 15 19 8 21 4 3 4 2 4
PT 22 4 0 17 4 3 8 18 2 14 21 4 17
CT 25 8 2 21 19 22 16 13 6 17 25 6 21
Key 15 19 8 21 4 3 4 2 4 15 19 8 21 4
PT 4 3 18 0 21 4 24 14 20 17 18 4 11 5
CT 19 22 0 21 25 7 2 16 24 6 11 12 6 9
Autokey system
The periodic nature of the keyword can be eliminated by using a non – repeating keyword that is as long
as the message itself.
Vigenére proposed Autokey system , in which a keyword is concatenated with the plaintext itself to provide
a running key.
Vernam Cipher
Need of ultimate defense against cryptanalytic attack
Length of the keyword = Length of the plaintext
No statistical relationship to it.
AT&T engineer named called Gilbert Vernam in 1918.
His system works on binary bits rather that letter.
The system expressed as follows :
Ci = Pi Ki