Cipher Algorithms
Introduction
• It uses a single key.
• The larger the key, the more the
secure is the cipher.
• Common algorithms are AES and
DES.
• There are 2 basic techniques of
encryption :- Substitution and
Transposition
• It is most widely used for online
communication.
Substitution Cipher
• Each letter on plain text is replaced
by a random letter for English
alphabet.
• There are two major types of
substitution cipher:- Monoalphabetic
and Polyalphabetic substitution
cipher.
• The most common examples are –
Caesar cipher, Mono alphabetic
cipher, Poly alphabetic cipher,
Playfair cipher and Hill cipher
Caesar cipher
• One of the simplest and oldest
techniques of cryptography.
• It is a type of substitution cipher
• Each letter in plain text is replaced
by another letter from English
alphabet based on the key.
Mono Alphabetic Substitution
Cipher
D H I R A J S I N G H
L R S X P N A S Z T U
Poly Alphabetic Substitution
Cipher
D H I R A J S I N G H
L R S X P N A B Z T U
Vignére cipher
Plain Text – Dhiraj
Singh
Key - password
D H I R A J S I N G H
p a s s w o r d p a s
Method 1 -> Without Matrix
Convert both plain text and key to integers. A=0, B=1, C=2,
………. Z=25
Encryption - Ei = (Pi + Ki ) mod 26
Decryption – Di = (Ei – Ki ) mod 26
Vignére cipher
D H I R A J S I N G H
3 7 8 17 0 9 18 8 13 6 7
p a s s w o r d p a s
15 0 18 18 22 14 17 3 15 0 18
P.T. 3 7 8 17 0 9 18 8 13 6 7
Key 15 0 18 18 22 14 17 3 15 0 18
Sum 18 7 26 35 22 23 35 11 28 6 25
Mod 18 7 0 9 22 23 9 11 2 6 25
26
C.T. S H A J W X J L C G Z
Play Fair cipher
Plain Text– Hello
world
Key – ALONE
H E L L O W O R L D
HE LX LO WO RL DZ
Cipher Text PA OW ON XL WC GX
The key should not have
same letters. A L O N E
B C D F G Pair the plain text.
The key should not have both
H I/J K M P
i and j Add x if letters repeat
Q R S T U
Both letters are in the same V W X Y Z Add z if end has one
row, then the encrypted text letter
is the next letter
Hill
Cipher
• The message is divided into (nx1)
matrices.
• The key is a (nxn) matrix.
• The determinant value of key
matrix ≠ 0
Hill
Cipher
• Plain Text – SKY
• Key –
GYBNQKURP
ENCRYPTION
G Y B 6 24 1 1 S
8 mod 26 K
N Q K 13 16 10
1 Y
U R P 20 17 15
0
2
(6*18)+(24*10)+(1*2 372
4) 4 634
= = mod 26
(13*18)+(16*10)+(10 890
*24)
(20*18)+(17*10)+(15 8 I
*24) = 10 = K
6 G
Stream vs Block cipher
Transposition
Cipher
• The position of letters in plain text
are switched.
• Also known as letter jumbling.
• Some of the examples are:-
• Rail Fence cipher
• Columnar transposition
• Double transposition
• All transposition ciphers are weak but
can be made stronger by combining
with each other.
Rail Fence cipher
Plain Text:- Dhiraj
Singh
Depth:- 2
D H I R A J
S I N G H
Cipher Text:-
DSHIINRGAHJ
Note:- Write down the plain text as a sequence of diagonals with depth ‘n’ and
then read it as a sequence of rows.
Columnar Transposition
Cipher
Plain Text:- Dhiraj
Singh
Key:- CRYPT (13524) 1 3 5 2 4
D H I R A
J S I N G
H X Y Z A
DJH RNZ HSX AGA IIY
Cipher Text:-
DJHRNZHSXAGAIIY
Note:- The key should be consisting of non repeating letters. In the key,
whatever appears first alphabetically will be numbered 1 and so on.