0% found this document useful (0 votes)
16 views16 pages

Lecture 6 - Application1-Cryptography

The document discusses the Hill cipher, a method of encryption and decryption using matrix multiplication. It outlines the steps for both processes, including the necessity for the encryption matrix to be invertible and its determinant to meet specific criteria. An example is provided to illustrate the encryption of the plaintext 'TOP SECRET MESSAGE' and the decryption process for a given ciphertext.

Uploaded by

plushamza31
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)
16 views16 pages

Lecture 6 - Application1-Cryptography

The document discusses the Hill cipher, a method of encryption and decryption using matrix multiplication. It outlines the steps for both processes, including the necessity for the encryption matrix to be invertible and its determinant to meet specific criteria. An example is provided to illustrate the encryption of the plaintext 'TOP SECRET MESSAGE' and the decryption process for a given ciphertext.

Uploaded by

plushamza31
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

Linear Algebra

Lecture 11:
Applications2: Cryptography

Instructor
Dr. Safaa Amin
Encryption and Decryption
Process

Plain Text Encryption Cipher Text


(original Text) (Encrypted Text)
P Using Key 𝐶 = 𝐴𝑃
Matrix A

Cipher Text Decryption


Plain Text
(Encrypted Text) (original Text)
Using
• For both encryption and decryption, the Hill cipher assigns numerical
values to each letter of an alphabet. Throughout this paper, we will
use the standard 26 character English alphabet and define the
following associations between letters in our alphabet and numbers.
Encryption with the Hill Cipher:
Key Matrix
• The encryption matrix (Key Matrix) must be
1- invertible because its inverse will be used to decrypt the cipher texts
created with the Hill cipher and this encryption matrix.
So .
2- The determinant of the encryption matrix must also be not divisible
by 13 and 2 (factors of 26)

 is OK
det ( 𝐴 ) =0 det ( 𝐵 )=4 (𝑑𝑖𝑣𝑖𝑠𝑖𝑏𝑙𝑒 𝑏𝑦 2) det ( 𝐶 )=13 ( 𝑑𝑖𝑣𝑖𝑠𝑖𝑏𝑙𝑒𝑏𝑦 13)
• As an example, to encrypt the plaintext “TOP SECRET MESSAGE” with n=2,
the process is as follows

Step 1: Choose a 2x2 encryption matrix. For this example, we will use the
matrix This matrix has the determinant . Since 11 is ≠ 0, this matrix is invertible.
11 is also not divisible by 2 or 13.

Step 2: Split the plaintext into blocks of size 2 (ignoring spaces), determine the
letters’ numerical values, and align these as column vectors. If the length of the
plaintext is not evenly divisible by 2, add a previously decided character to the
end of the string until the plaintext is evenly divisible by 2.
Step 3: Multiply each of these column vectors by the encryption
matrix and take modulo 26 of the result.
‫‪85/26 =3.269230…..‬‬
‫‪3.269230…..-3= 0.269230…..‬‬
‫‪0.269230…..*26=7‬‬
‫هو ده معناه ان الحرف رقم ‪ 85‬هنجيبه‬
‫ازاى؟؟؟‬
‫هنلف على الحروف كلها ‪ 3‬مرات وفى‬
‫اللفة الرابعة هقف عند رقم ‪7‬‬
‫اللى هو حرف ال‪H‬‬

‫‪85/26 =7.42303…..‬‬
‫‪7.42303….. -7= 0.42303‬‬
‫‪0.42303..*26=11‬‬
‫هو ده معناه ان الحرف رقم ‪ 193‬هنجيبه‬
‫ازاى؟؟؟‬
‫هنلف على الحروف كلها ‪ 7‬مرات وفى‬
‫اللفة الثامنة هقف عند رقم ‪11‬‬
Step 4: Convert each of the matrices obtained in step 3 to their
alphabetical vectors and combine them to produce the cipher text.

This completes the process of the Hill cipher’s encryption by matrix


multiplication. We can see that the plaintext “TOP SECRET MESSAGE”
encodes to “HLDTQIHJDXWQCMAG.” It is important to note
The decryption process
• The decryption which is the process of converting the ciphertext into
plaintext could also be summarized in four basic steps:
Step 1: Get the inverse of the matrix A say ;
Step 2: Change each ciphertext to its numerical value.
Step 3: Put each ciphertext in a ( nx1 ) column vector say C .
Step 4: Get each plaintext vector by multiplying with C , and convert
each plaintext vector to its letter in the alphabet. The decryption
algorithm of this method is:
Step 1: Get the inverse of the matrix A say

H
11x????= 1 modulo 26

‫ فى كام‬11 ‫يعنى اضرب ال‬


26 ‫يعطى رقم لما اقسمة على‬
1 ‫يتبقى‬
11*19=209
209/26=٨.٠٣٨٤٦١٥٣٨٤٦١٥٣٨
11 7 5 3 1 0.٠٣٨٤٦١٥٣٨٤٦١٥٣٨ *26=1
19 15 21 9 1
‫‪38/26 =1.461538…..‬‬
‫‪1.461538….. -1= 0. 461538…..‬‬
‫‪0. 461538…..*26=12‬‬
‫هو ده معناه ان الحرف رقم ‪38-‬‬
‫هنجيبه ازاى؟؟؟‬
‫هنرجع للخلف على الحروف كلها مرة‬
‫واحدة وفى اللفة التانية هقف عند‬
‫الحرف رقم ‪ 12‬من االخر يعنى رقم‬
Example:
3- Multiply each of these column vectors by the decryption matrix
calculated in step 1 and take modulo 26 of the result.
• Decode the message "CKHWSBQWgiven

1. Find the inverse of the enciphering matrix.

 2 1
det   2 2   1 1 3
 1 2
 3  1 mod 26  9

1.1. Multiply the reciprocal modulo 26 by the enciphering matrix.

18 −9
𝐴 = 9
−1
=ቂ ቃ
 2  1
 −9 18
 1 2 
1. Convert the ciphertext vectors into plaintext vectors.

• C K / H W / S B /Q Y

• 3 11/8 23 /19 2/17 25

C   18  9  3    45  7   G
      mod 26      
K    9 18  11  171  15  O 

H   18  9  8    63 15  O 
      mod 26      
W    9 18   23  342   4   D

S   18  9 19  324   12   L
      mod 26   
B    9 18   2    135  21  U

Q   18  9  17   81   3  C
      mod 26  
Y    9 18   25  297  11  K
𝟐𝟏
A- Decode the message "ANVBKBGAPB"which is a Hill cipher with enciphering matrix ቂ𝟏 𝟏ቃ
given

Answer:

𝐴−1 = 1 
 1  1

 1 2 
A N / V B / K B /G A /P B
1 14/ 22 2/ 11 2/ 7 1/ 16 2

 1  1 1 −13 13 𝑀
𝑃1 =   1 2  ቂ14ቃ = ቂ 27 ቃ 𝑚𝑜𝑑 26 = ቂ 1 ቃ = ቂ 𝐴ቃ
 
 1  1 22 20 20 𝑇
𝑃2 =   1 2  ቂ 2 ቃ = ቂ−18ቃ 𝑚𝑜𝑑 26 = ቂ 8 ቃ = ቂ𝐻ቃ
 
 1  1 11 9 9 𝐼
𝑃3 =   1 2  ቂ 2 ቃ = ቂ−7ቃ 𝑚𝑜𝑑 26 = ቂ19ቃ = ቂ𝑆ቃ
 
 1  1 7 6 6 𝐹
𝑃4 =   1 2  ቂ1ቃ = ቂ−5ቃ 𝑚𝑜𝑑 26 = ቂ21ቃ = ቂ𝑈ቃ
 
 1  1 16 14 14 𝑁
𝑃5 =   1 2  ቂ 2 ቃ = ቂ−12ቃ 𝑚𝑜𝑑 26 = ቂ14ቃ = ቂ𝑁ቃ
 
Plain Text: "Math I s Funn"

You might also like