Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 13

FACULTY OF COMPUTER AND MATHEMATICAL SCIENCES

MAT263
LINEAR ALGEBRA I

CASE STUDY
CRYPTOGRAPHY

GROUP
D1CS1105C

LECTURER’S NAME
MADAM WAN FAIZAH BINTI WAN YAACOB

MEMBERS’ NAME
NAME MATRIC NO.
SITI NOR SYAMIMI BINTI AHMAD 2018411986
ZAHARI
NIK NUR AFIFAH BINTI SUHAIMI 2018473342
TUAN NURNAJIHAH BINTI TUAN MD 2018407206
ZAZAWI

SUBMISSION DATE
6TH February 2021
CONTENTS

Contents Page

1.0 INTRODUCTION……………………………………………………………….. 1

2.0 OBJECTIVE…………………………………………………………………….. 2

3.0 METHODOLOGY………………………………………………………………. 3

3.1 HILL CIPHER………………………………………………………….. 3

3.2 CEASER CIPHER…………………………………………………….. 3

4.0 RESULT…………………………………………………………………………. 4

4.1 ENCRYPTION AND DECRYPTION USING HILL CIPHER………. 4

4.1.1 ENCRYPTION METHOD: HILL CIPHER………………… 4-5

4.1.2 DECRYPTION METHOD: HILL CIPHER………………… 6

4.2 ENCRYPTION AND DECRYPTION USING CAESER CIPHER…. 7

4.2.1 ENCRYPTION METHOD: CAESER CIPHER…………… 7-8

4.2.2 DECRYPTION METHOD: CAESER CIPHER…………… 9-10

5.0 DISCUSSION…………………………………………………………………… 11
1.0 INTRODUCTION

Cryptography is the study of the techniques of writing and decoding messages in


code. In cryptography language, codes are called the cipher. Cipher is an algorithm used to
solve the encryption and decryption. Codes in cryptography are divided by two which are
plain text where the message or information that is being encrypted and cipher text where
the message or information that is created after the cipher has been used. Cryptography
used for the security needed for a password. It is important because the sensitive data that
flow on the internet might be monitor easily by unintended third-hand parties.

1
2.0 OBJECTIVES

The purpose of cryptography is to protect data transmitted in the likely presence of


an adversary a cryptography transformation of data is a procedure by which plain text data is
disguised, or encrypted, resulting in an altered text, called cypher text, that does not reveal
the original input. The cipher text can be reverse-transformed by a designated recipient so
that the original plaintext can be recovered. Cryptography plays an essential role in
authentication, data confidentiality, data integrity and more.

There are five primary functions of cryptography:


I. Privacy/confidentiality: Ensuring that no one can read the message except the
intended receiver.
II. Authentication: The process of proving one's identity.
III. Integrity: Assuring the receiver that the received message has not been
altered in any way from the original.
IV. Non-repudiation: A mechanism to prove that the sender really sent this
message.
V. Key exchange: The method by which crypto keys are shared between sender
and receiver.

2
3.0 METHODOLOGY
3.1 Hill Cipher

The method that we use is Hill Cipher. Hill Cipher is a symmetrical block
cipher technique by a mathematician, Lester Hill; is a polygraphist cipher based on
linear transformation. Hill cipher is a block cipher algorithm where plain text is divided
into a block of the same size. Hill cipher also a polygraphed substitution cipher based
on linear algebra. Each letter is represented by a number modulo 26. Often the
simple scheme A = 1, B = 2… and so on until Z = 26 is used, but this is not an
essential feature of the cipher. To encrypt a message, each block of n letters
(considered as an n-component vector) is multiplied by an invertible n × n matrix,
against modulus 26. Each block of plain text letter is then converted into a vector of
number and is dotted with the matrix. The result is then converted back to letter and
the cipher text message is produced. To decrypt the message, each block is
multiplied by the inverse of the matrix used for encryption. The matrix used for
encryption is the cipher key, and it should be chosen randomly from the set of
invertible n × n matrices (modulo 26).

3.2 Caesar Cipher

Another method is to use Caesar Cipher. It is one of the simplest in many


other techniques of encryption. The technique is simply just by substitutes the letter
with another letter that has been shifted by a fixed number of positions. For example,
with a shift of 2, A would be replaced by C, C would become E and so on. Moreover,
an integer value, known as the number of positions for the alphabet to be shifted to
the left is needed to cipher a given text. Modular arithmetic can represent the
encryption by first transforming the letters into numbers, according to the given
scheme which will be state in the given table below.

3
4.0 RESULT

4.1 Encryption & Decryption using Hill Cipher

4.1.1 Encryption Method: Hill Cipher


One of the examples to encrypt words is shown below:
Problem: Encode the message “CHANGE” by using Hill cipher algorithm where

the matrix is A: (13 21)


Solution: We use the table below to convert letters in the message to the
numerical values.

A B C D E F G H I J
1 2 3 4 5 6 7 8 9 10
K L M N O P Q R S T
11 12 13 14 15 16 17 18 19 20
U V W X Y Z
21 22 23 24 25 26

Step 1: Change the alphabet using above table.

C H A N G E
3 8 1 14 7 5

4
Step 2: Multiply the encrypted matrix with given matrix A.

Encryption algorithm here is given as C= AP (mod N)

( aan111 a 1n
ann ) ( ppn111 p 1n
pnn )
(mod N)

3 8 3+24 6+8

[ ][
1 14
7 5
1 2
3 1
= ] [ ]
1+42 2+14 (mod 26)
7+15 14+5

27 14

[ ]
= 43 16
22 19
(mod 26)

1 14

[ ]
= 17 16
22 19

Step 3: Change the encrypted matrix to cipher text.

A N Q P V S
1 14 17 16 22 19

The message after encrypt will be “ANQPVS”

5
4.1.2 Decryption Method: Hill Cipher
To decrypt the matrix back into plaintext, multiply it by the inverse of the cipher
matrix:

Step 1: Inverse the cipher matrix


1 d −b
Formula for the inverse, A-1 = [
ad−bc −c a ]
1 1 −2
A-1 = x
1−6 −3 1 [ ]
−1 1 −2
= [
5 −3 1 ]
−1 2
=
5
3
5
[ ] 5
−1
5

Step 2: Multiply it by the inverse of the cipher matrix

( −275 )+( 425 ) ( 545 )+( −145 )


[ ][
27 14
43 16
22 19
−1
5
3
5
2
5
−1
5
] [
= (
−43
5 ) 48 86
+( ) ( ) + (
5 5
−16
5 )

( −225 )+( 575 ) ( 445 )+( −195 )


3 8
]
[ ]
= 1 14
7 5

Step 3: Change the value to plaintext do decrypt the message.


C H A N G E
3 18 1 14 7 5

The message after decrypt will be “CHANGE”

6
4.2 Encryption & Decryption using Caesar Cipher

4.2.1 Encryption Method: Caeser Cipher


One of the examples to encrypt words is shown below:

Problem: Encode the message “CHANGE” by using Caesar cipher algorithm with

a left shift (n) of 16 and matrix A: (13 21)


From the original table, the shifted table were resulted from n = 16.

K L M N O P Q R S T
1 2 3 4 5 6 7 8 9 10
U V W X Y Z A B C D
11 12 13 14 15 16 17 18 19 20
E F G H I J
21 22 23 24 25 26

Step 1: Change the alphabet using the shifted table.

C H A N G E
19 24 17 4 23 21

7
Step 2: Multiply the encrypted matrix with given matrix A.
Encryption algorithm here is given as C= AP (mod N) , N = 26

19 24 19+72 38+ 24

[ ][
17 4
23 21
1 2
3 1
=] [ ]
17+12 34+ 4 (mod 26)
23+63 46+21
91 62

[ ]29 38 (mod 26)


86 67
13 10

[ ]
= 3 12
8 15

The message after encrypt will be “WTMVRY”.

8
4.2.2 Decryption Method: Caesar Cipher

To decrypt the matrix back into plaintext, multiply the encrypted matrix by the
inverse of the encoding matrix as the steps below:

Step 1: Inverse the cipher matrix.


1 d −b
Formula for the inverse, A-1 = [
ad−bc −c a ]
1 1 −2
A-1 = x
1−6 −3 1 [ ]
−1 1 −2
= [
5 −3 1 ]
−1 2
=
5
3
5
[ ] 5
−1
5

Step 2 : Change the encrypted cipher text back to its numerical value.

W T M V R Y
13 10 3 12 8 15

Step 3: Multiply it by the inverse of the cipher matrix

( −915 )+( 1865 ) ( 1825 )+( −625 )


[ ][
13 10
3 12
8 15
−1
5
3
5
2
5
−1
5
] [
= (
−29
5 )+(
114
5
58
) ( ) +(
5
−38
5 )

( −865 )+( 2015 ) ( 1725 )+( −675 )


19 24
]
[ ]
= 17 4
23 21

9
Step 4: Change the value to plaintext do decrypt the message.
C H A N G E
19 24 17 4 23 21

The message after decrypt will be “CHANGE”.

10
5.0 DISCUSSION

Firstly, we need to identify how to translate the plain text to cypher text and vice
versa. After thorough research being done, we have identified two ways to convert plain text
into cypher text which is by using the Hill cypher algorithm and Caesar cypher algorithm.
Both algorithms use a formula to encrypt the plain text into cypher text and encrypt process
uses the inverse matrix of the formula to decrypt the cypher text into plain text. The cypher
text can only be decrypted with a key matrix. Moreover, for Caesar cypher, the number of
positions the alphabets shifted needs to be stated as by then, only it can be decrypted. With
the help of the Hill cypher and Caesar cypher algorithm, the process of cryptography is
successfully done and with this method, the received message can be encoded to make
sure that the message stays hidden if they don't have the key matrix and cannot be identified
by other people.
For example, if the military wants to relay the message to their squadron, the army’s
captain can use the Caesar cypher algorithm to encode the message. This can ensure that
the message cannot be read by the enemy even if they intercepted it and they need to
decrypt the message if they want to read it. Although cypher algorithm has a drawback,
which is, it encrypts identical plain text blocks to identical cypher text blocks that reveal
patterns in the plain text, there is other research paper out there that have found the solution
to these disadvantages such as by adjusting the encryption key from one block to another.

11

You might also like