0% found this document useful (0 votes)
22 views23 pages

Substitution Technique 03

Uploaded by

abc abc
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views23 pages

Substitution Technique 03

Uploaded by

abc abc
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 23

Substitution

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

 Polygraphic substitution cipher invented by Lester S. Hill in 1929.


 Operates on letters blocks and uses matrix multiplication.
 Strength lies in encrypting multiple letters simultaneously, making it resistant to frequency analysis.
 Multi-letter cipher.
 Encrypts a group of letter : diagraph , trigraph or polygraph.
Hill cipher
Review few terminologies from linear algebra.
Concepts to be known :

 Matrix arithmetic modulo 26


Square matrix
Determinant
Multiplicative inverse
The Hill Algorithm

This can expressed as ,

C = E(K,P) = p*k mod 26

P = D (K,C) = C , (K – 1) mod 26 = P*K*(K-1) mod 26

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

( 15*17+0*21+24*2 15*17+0*18+24*2 15*5+0*21+24*19 ) mod 26


( 303 303 531 ) mod 26
( 17 17 11)
( R R L)
Hill Cipher - Decryption

This can be expressed as ,

Encryption :

C = E (K,P) = P*K mod 26

Decryption :

P = D (K,C) = C*K-1 mod 26

Decryption requires K-1 , the inverse matrix K.


The Hill Algorithm

Decryption requires K-1 , the inverse matrix K

= 17 (18*19 – 2*21) – 17 (21*19 – 2*21) + 5 (21*2 – 2*18) mod 26


K = 1
-1
= 17 (342 – 42 ) – 17 (399-42 ) + 5 (42-36) mod 26
* Adj k
Det K = 17 ( 300 ) – 17 ( 357 ) + 5 ( 6 ) mod 26
= 5100 – 6069 + 30 mod 26
To find Det K , Adj K =-939 mod 26
= - 3 mod 26
= 23 ( Det K)
17 17 5
Det 21 18 21 mod 26
2 2 19 17 17 5 17 17
Adj K = 21 18 21 21 18
2 2 19 2 2
Finding Adj K

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

17 17 5 17 17 =18*19 – 2*21 2*5 – 17*19 17*21 – 18*5


Adj K = 21 18 21 21 18 =21*2 -19*21 19*17 – 5*2 5*21 – 21*17
2 2 19 2 2 = 21*2 – 2*18 2*17 – 17*2 17* 18 – 21*17
17 17 5 17 17 = 300 -313 267
21 18 21 21 18 = -357 313 -252 mod 26
=6 0 - 51
14 -1 7
Performing the operation – Column wise
-19 1 -18 mod 26
Entering the Matrix – Row wise
6 0 - 25
Decryption required K-1 , the inverse matrix K.

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

= (17*4+17*15+14*24 17*9+17*17+14*0 14*15+17*6+14*17) mod 26


= ( 587 442 544 ) mod 26
= ( 15 0 24 ) mod 26
= PAY
Vigenére Cipher
It consists of the 26 Caesar ciphers with shifts of 0 through 25.

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

Cipher text : ZICVTWQNGRZGVTWAVZHCQYGLMG


Vigenére Cipher -
Cryptanalysis
Determining the length of the keyword.
Key and the plaintext share the same frequency distribution of letters , a
statistical technique can be applied.

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

You might also like