Hill Cipher

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 24

A B C D E F G H I J K L M

Q W E R T Y U I O P A S D

N O P Q R S T U V W X Y Z
F G H J K L Z X C V B N M

Unencrypted = HELLO WORLD

Encrypted = ITSSG VKGSR


 Encrypts letters in groups
 Frequency analysis more difficult
 Polygraphic substitution cipher
 Uses matrices to encrypt and decrypt
 Uses modular arithmetic (Mod 26)
 For a Mod b, divide a by b and take the
remainder.
14 ÷ 10 = 1 R 4
14 Mod 10 = 4
24 Mod 10 = 4
 Inverse of 2 is ½ (2 · ½ = 1)
 Matrix Inverse: AA-1= I
 Modular Inverse for Mod m: (a · a-1) Mod m =
1
 For Modular Inverses, a and m must NOT
have any prime factors in common
A 1 2 5 7 9 11 15 17 19 21 23 25
A-1 1 9 21 15 3 19 7 23 11 5 17 25

Example – Find the Modular Inverse of 9 for Mod 26

9 · 3 = 27

27 Mod 26 = 1

3 is the Modular Inverse of 9 Mod 26


 One matrix to encrypt, one to decrypt
 Must be n x n, invertible matrices
 Decryption matrix must be modular inverse
of encryption matrix in Mod 26
 Calculate determinant of first matrix A, det A
 Make sure that det A has a modular inverse
for Mod 26
 Calculate the adjugate of A, adj A
 Multiply adj A by modular inverse of det A
 Calculate Mod 26 of the result to get B
 Use A to encrypt, B to decrypt
 Assign each letter in alphabet a number
between 0 and 25
 Change message into 2 × 1 letter vectors
 Change each vector into 2 × 1 numeric
vectors
 Multiply each numeric vector by encryption
matrix
 Convert product vectors to letters
A B C D E F G H I J K L M
0 1 2 3 4 5 6 7 8 9 10 11 12

N O P Q R S T U V W X Y Z
13 14 15 16 17 18 19 20 21 22 23 24 25
Message to encrypt = HELLO WORLD
HELLO WORLD has been encrypted to
SLHZY ATGZT
 Change message into 2 × 1 letter vectors
 Change each vector into 2 × 1 numeric
vectors
 Multiply each numeric vector by decryption
matrix
 Convert new vectors to letters
Message to encrypt = SLHZYATGZT
SLHZYATGZT has been decrypted to
HELLO WORLD
 Creating valid encryption/decryption
matrices is the most difficult part of Hill
Ciphers.
 Otherwise, Hill Ciphers use simple linear
algebra and modular arithmetic

You might also like