Professional Documents
Culture Documents
By
Chayanan Anu-ekjit
6261294
Grade 11 Section 1101
Present
Ms. Parunee Kaosayapandhu
The method of transforming regular plain language into incomprehensible language
and vice versa is known as Cryptography. It is a means of storing and sending data in a
certain format so that only those who are supposed to read and process it may do so. Here,
matrix is used as code and key. The key matrix is used to encrypt messages, while its inverse
is used to decode encrypted messages.
In this document, I will demonstrate the processes of cryptography using the secret
love message that our group came up with.
Encryption
First step is to convert the original text message, including punctuations and blank
spaces, into numbers by using the coding system as shown below:
A 1 R 18
B 2 S 19
C 3 T 20
D 4 U 21
E 5 V 22
F 6 W 23
G 7 X 24
H 8 Y 25
I 9 Z 26
J 10 Blank 0
1
K 11 , 27
L 12 - 28
M 13 ? 29
N 14 ! 30
O 15 O' 31
P 16 . 32
Q 17
Uncoded matrix
The message is divided into two 5x5 matrices. The first 25 characters are converted
into numbers in matrix 𝐴 and the rest 25 characters are converted to matrix 𝐵.
𝐴:
25 15 21 31 18
5 0 1 3 21
20 5 28 25 30
0 9 0 11 14
15 23 0 25 15
𝐵:
21 0 12 9 11
5 0 1 4 4
9 14 7 0 14
21 13 2 5 18
19 0 0 0 0
2
Encryption matrix
In order to encrypt the codes, it is required for the encryption matrix. Here is the
encryption matrix, 𝐸, with the dimension of 5x5 that I came up with, which also has a
determinant equivalent to 1.
𝐸:
1 2 5 0 7
1 3 6 3 12
2 5 12 7 21
2 5 12 8 25
1 3 6 3 13
To verify the determinant of 1 of the matrix. I utilize the Gaussian Elimination method.
Step 1: 𝑅2 − 𝑅1 = 𝑅2
1 2 5 0 7
0 1 1 3 5
2 5 12 7 21
2 5 12 8 25
1 3 6 3 13
Step 2: 𝑅4 − 𝑅3 = 𝑅4
1 2 5 0 7
0 1 1 3 5
2 5 12 7 21
0 0 0 1 4
1 3 6 3 13
3
Step 3: 𝑅5 − 𝑅1 = 𝑅5
1 2 5 0 7
0 1 1 3 5
2 5 12 7 21
0 0 0 1 4
0 1 1 3 6
Step 4: 𝑅3 − (2)𝑅1 = 𝑅3
1 2 5 0 7
0 1 1 3 5
0 1 2 7 7
0 0 0 1 4
0 1 1 3 6
Step 5: 𝑅5 − 𝑅2 = 𝑅5
1 2 5 0 7
0 1 1 3 5
0 1 2 7 7
0 0 0 1 4
0 0 0 0 1
Step 6: 𝑅3 − 𝑅2 = 𝑅3
1 2 5 0 7
4
0 1 1 3 5
0 0 1 4 2
0 0 0 1 4
0 0 0 0 1
As shown in the matrix above, all of the entries in the diagonal are all 1, implying that
now the matrix is in a row-echelon form. Moreover, all its entries below the main diagonal
are zero, meaning that this matrix is an upper triangular matrix. Hence, the determinant can
be calculated by multiplying the entries in the main diagonal.
𝐷𝑒𝑡(𝐸) = 1 × 1 × 1 × 1 × 1 = 1
Therefore, now that the determinant is verified, we can now proceed encoding the
uncoded matrices, 𝐴 & 𝐵.
Encoded matrix
𝑈𝑛𝑐𝑜𝑑𝑒𝑑 𝑚𝑎𝑡𝑟𝑖𝑥 × 𝐸𝑛𝑐𝑟𝑦𝑝𝑡𝑖𝑜𝑛 𝑚𝑎𝑡𝑟𝑖𝑥 = 𝐸𝑛𝑐𝑜𝑑𝑒𝑑 𝑚𝑎𝑡𝑟𝑖𝑥
𝐴(𝑜𝑟𝐵) × 𝐸 = 𝐴'(𝑜𝑟 𝐵')
5 0 1 3 21 1 3 6 3 12
20 5 28 25 30 × 2 5 12 7 21
0 9 0 11 14 2 5 12 8 25
15 23 0 25 15 1 3 6 3 13
5 0 1 4 4 1 3 6 3 12
5
9 14 7 0 14 × 2 5 12 7 21
21 13 2 5 18 2 5 12 8 25
19 0 0 0 0 1 3 6 3 13
To illustrate the multiplying process, I will demonstrate the process of finding the
entry located on the intersection between the first row and the first column of the matrix 𝐴',
thus, finding entry 𝐴'11.
𝐴':
To find entry 𝐴'11, we multiply the row by the column. In this example, we are
working on the first row and the first column. We pair the first members (25 and 1), multiply
them, repeat for the second members (15 and 1) and third members (21 and 2), and so on.
Then, we add them all together.
𝐴':
6
𝐴'41 𝐴'42 𝐴'43 𝐴'44 𝐴'45
Repeat the process for all of the entries as well as for the uncoded matrix 2,𝐵'. Thus,
we get the encoded matrix 1 and encoded matrix 2, 𝐴' & 𝐵':
𝐴':
162 409 947 494 1805
34 93 199 94 404
𝐵':
74 180 423 189 767
19 47 109 51 208
19 38 95 0 133
7
Decryption
To further proceed decrypting the messages, it is required for an inverse of the
encryption matrix. Here, I use the Gauss-Jordan Elimination method to find the inverse of
matrix 𝐸.
Inverse matrix
Our aim is to acquire the identity matrix in the first block. If this is the case, the
−1
matrix obtained in the second block will be the inverse matrix of 𝐸or 𝐸 . If it is impossible,
it indicates that the matrix 𝐸 is not invertible and so has no inverse.
As seen below, we put matrix 𝐸 in the first block and Identity matrix I with the same
dimension of 5x5 in the second block, separated by a line. The resulting matrix is known as
an augmented matrix.
1 2 5 0 7 1 0 0 0 0
1 3 6 3 12 0 1 0 0 0
2 5 12 7 21 0 0 1 0 0
2 5 12 8 25 0 0 0 1 0
1 3 6 3 13 0 0 0 0 1
8
Then, we carry on with the Gaussian Elimination method to first obtain the
row-echelon form.
Step 1: 𝑅2 − 𝑅1 = 𝑅2
1 2 5 0 7 1 0 0 0 0
0 1 1 3 5 -1 1 0 0 0
2 5 12 7 21 0 0 1 0 0
2 5 12 8 25 0 0 0 1 0
1 3 6 3 13 0 0 0 0 1
Step 2: 𝑅4 − 𝑅3 = 𝑅4
1 2 5 0 7 1 0 0 0 0
0 1 1 3 5 -1 1 0 0 0
2 5 12 7 21 0 0 1 0 0
0 0 0 1 4 0 0 -1 1 0
1 3 6 3 13 0 0 0 0 1
Step 3: 𝑅5 − 𝑅1 = 𝑅5
1 2 5 0 7 1 0 0 0 0
0 1 1 3 5 -1 1 0 0 0
2 5 12 7 21 0 0 1 0 0
0 0 0 1 4 0 0 -1 1 0
0 1 1 3 6 -1 0 0 0 1
Step 4: 𝑅3 − (2)𝑅1 = 𝑅3
9
1 2 5 0 7 1 0 0 0 0
0 1 1 3 5 -1 1 0 0 0
0 1 2 7 7 -2 0 1 0 0
0 0 0 1 4 0 0 -1 1 0
0 1 1 3 6 -1 0 0 0 1
Step 5: 𝑅5 − 𝑅2 = 𝑅5
1 2 5 0 7 1 0 0 0 0
0 1 1 3 5 -1 1 0 0 0
0 1 2 7 7 -2 0 1 0 0
0 0 0 1 4 0 0 -1 1 0
0 0 0 0 1 0 -1 0 0 1
Step 6: 𝑅3 − 𝑅2 = 𝑅3
1 2 5 0 7 1 0 0 0 0
0 1 1 3 5 -1 1 0 0 0
0 0 1 4 2 -1 -1 1 0 0
0 0 0 1 4 0 0 -1 1 0
0 0 0 0 1 0 -1 0 0 1
Now that we acquire a row-echelon form, we will proceed with the Gauss-Jordan
elimination method to succeed the reduced row-echelon form.
Step 7: 𝑅1 − (2)𝑅2 = 𝑅1
1 0 3 -6 -3 3 -2 0 0 0
10
0 1 1 3 5 -1 1 0 0 0
0 0 1 4 2 -1 -1 1 0 0
0 0 0 1 4 0 0 -1 1 0
0 0 0 0 1 0 -1 0 0 1
Step 8: 𝑅2 − 𝑅3 = 𝑅2
1 0 3 -6 -3 3 -2 0 0 0
0 1 0 -1 3 0 2 -1 0 0
0 0 1 4 2 -1 -1 1 0 0
0 0 0 1 4 0 0 -1 1 0
0 0 0 0 1 0 -1 0 0 1
Step 9: 𝑅3 − (4)𝑅4 = 𝑅3
1 0 3 -6 -3 3 -2 0 0 0
0 1 0 -1 3 0 2 -1 0 0
0 0 1 0 -14 -1 -1 5 -4 0
0 0 0 1 4 0 0 -1 1 0
0 0 0 0 1 0 -1 0 0 1
1 0 3 -6 -3 3 -2 0 0 0
0 1 0 -1 3 0 2 -1 0 0
0 0 1 0 -14 -1 -1 5 -4 0
0 0 0 1 0 0 4 -1 1 -4
11
0 0 0 0 1 0 -1 0 0 1
1 0 0 -6 39 6 1 -15 12 0
0 1 0 -1 3 0 2 -1 0 0
0 0 1 0 -14 -1 -1 5 -4 0
0 0 0 1 0 0 4 -1 1 -4
0 0 0 0 1 0 -1 0 0 1
Step 12: 𝑅2 + 𝑅4 = 𝑅2
1 0 0 -6 39 6 1 -15 12 0
0 1 0 0 3 0 6 -2 1 -4
0 0 1 0 -14 -1 -1 5 -4 0
0 0 0 1 0 0 4 -1 1 -4
0 0 0 0 1 0 -1 0 0 1
1 0 0 0 39 6 25 -21 18 -24
0 1 0 0 3 0 6 -2 1 -4
0 0 1 0 -14 -1 -1 5 -4 0
0 0 0 1 0 0 4 -1 1 -4
0 0 0 0 1 0 -1 0 0 1
12
1 0 0 0 0 6 64 -21 18 -63
0 1 0 0 3 0 6 -2 1 -4
0 0 1 0 -14 -1 -1 5 -4 0
0 0 0 1 0 0 4 -1 1 -4
0 0 0 0 1 0 -1 0 0 1
1 0 0 0 0 6 64 -21 18 -63
0 1 0 0 0 0 9 -2 1 -7
0 0 1 0 -14 -1 -1 5 -4 0
0 0 0 1 0 0 4 -1 1 -4
0 0 0 0 1 0 -1 0 0 1
1 0 0 0 0 6 64 -21 18 -63
0 1 0 0 0 0 9 -2 1 -7
0 0 1 0 0 -1 -15 5 -4 14
0 0 0 1 0 0 4 -1 1 -4
0 0 0 0 1 0 -1 0 0 1
As shown above is a matrix with a reduced row-echelon form on the first block, and
−1
an inverse of matrix 𝐸or 𝐸 on the second block.
−1
𝐸 :
6 64 -21 18 -63
0 9 -2 1 -7
-1 -15 5 -4 14
13
0 4 -1 1 -4
0 -1 0 0 1
Verification
We can as well verify if the inverse matrix is correct by multiplying the matrix to its
inverse. If the inverse matrix is correct, the product of the matrices will be the identity matrix:
−1
𝐸 ×𝐸 = 𝐼
−1
𝐸:Encryption matrix 𝐸 :Inverse Encryption Matrix
1 2 5 0 7 6 64 -21 18 -63
1 3 6 3 12 0 9 -2 1 -7
2 5 12 7 21 × -1 -15 5 -4 14
2 5 12 8 25 0 4 -1 1 -4
1 3 6 3 13 0 -1 0 0 1
1 0 0 0 0
14
0 1 0 0 0
= 0 0 1 0 0
0 0 0 1 0
0 0 0 0 1
Decoded matrix
𝑈𝑛𝑐𝑜𝑑𝑒𝑑 𝑚𝑎𝑡𝑟𝑖𝑥 × 𝐸𝑛𝑐𝑟𝑦𝑝𝑡𝑖𝑜𝑛 𝑚𝑎𝑡𝑟𝑖𝑥 = 𝐸𝑛𝑐𝑜𝑑𝑒𝑑 𝑚𝑎𝑡𝑟𝑖𝑥
𝐴(𝑜𝑟𝐵) × 𝐸 = 𝐴'(𝑜𝑟 𝐵')
−1 −1
𝐴(𝑜𝑟𝐵) × 𝐸 × 𝐸 = 𝐴'(𝑜𝑟 𝐵') × 𝐸
−1
𝐴(𝑜𝑟𝐵) × 𝐼 = 𝐴'(𝑜𝑟 𝐵') × 𝐸
−1
𝐴(𝑜𝑟𝐵) = 𝐴'(𝑜𝑟 𝐵') × 𝐸
Thus,
𝐸𝑛𝑐𝑜𝑑𝑒𝑑 𝑚𝑎𝑡𝑟𝑖𝑥 × 𝐼𝑛𝑣𝑒𝑟𝑠𝑒 𝑜𝑓 𝐸𝑛𝑐𝑟𝑦𝑝𝑡𝑖𝑜𝑛 𝑚𝑎𝑡𝑟𝑖𝑥 = 𝐷𝑒𝑐𝑜𝑑𝑒𝑑 𝑚𝑎𝑡𝑟𝑖𝑥
−1
𝐴'(𝑜𝑟𝐵') × 𝐸 = 𝐴(𝑜𝑟 𝐵)
−1
𝐴':Encoded Matrix 1 𝐸 :Inverse Encryption Matrix
162 409 947 494 1805 6 64 -21 18 -63
34 93 199 94 404 0 9 -2 1 -7
15
161 410 946 501 1803 × -1 -15 5 -4 14
−1
𝐵':Encoded Matrix 1 𝐸 Inverse Encryption Matrix
74 180 423 189 767 6 64 -21 18 -63
19 47 109 51 208 0 9 -2 1 -7
19 38 95 0 133 0 -1 0 0 1
𝐴:
25 15 21 31 18
5 0 1 3 21
20 5 28 25 30
0 9 0 11 14
15 23 0 25 15
𝐵:
21 0 12 9 11
5 0 1 4 4
16
9 14 7 0 14
21 13 2 5 18
19 0 0 0 0
Decoded message
Now that the decoded matrices are obtained, we can decode the message by using the
same coding system as when we converted the messages into numbers
𝐴:
Y O U O' R A 1 R 18
E A C U B 2 S 19
T E - Y ! C 3 T 20
I K N D 4 U 21
O W Y O E 5 V 22
𝐵: F 6 W 23
U L I K G 7 X 24
17
E A D D H 8 Y 25
I N G N I 9 Z 26
U M B E R J 10 Blank 0
S K 11 , 27
L 12 - 28
M 13 ? 29
N 14 ! 30
O 15 O' 31
P 16 . 32
Q 17
GG Sheet link:
https://docs.google.com/spreadsheets/d/1qQFiumEOhTxo_zkwSTfVSa40ynQUMf_aEHNeNXRUPj0
/edit#gid=0
18