LIST OF TABLES, FIGURES, GRAPHSFigure 1: Types of substitution ciphers ...5 Figure 2: Relative frequency of letters in the English alphabet...7 Figure 3: Encryption with 100 words...9 Fi
Trang 1MIDTERM ESSAY
APPLIED PROBABILITY AND
STATISTICS FOR IT
Instructing Lecturer: MR NGUYEN QUOC BINH Student’s name: HUYNH NHAT NAM – 520H0660
Class : 20H50302 Course : 24
HO CHI MINH CITY, 2021
Trang 2FACULTY OF INFORMATION TECHNOLOGY
MIDTERM ESSAY
APPLIED PROBABILITY AND
STATISTICS FOR IT
Instructing Lecturer: MR NGUYEN QUOC BINH Student’s name: HUYNH NHAT NAM – 520H0660
Class : 20H50302 Course : 24
HO CHI MINH CITY, 2021
Trang 3I received eager assistance from speakers and classmates in order to produce such a comprehensive and high-quality report
I would also want to thank lecturer Mr Nguyen Quoc Binh for his great knowledge and eager assistance Mr Binh, thank you for your enthusiasm in teaching, educating, and equipping us with the essential knowledge, as well as for establishing the most conducive conditions for us to complete this report
Also, thank you to Ton Duc Thang University for providing us with a modern and advanced learning atmosphere
With a lot of effort and hard work, we were able to finish this report However, this report is bound to contain errors We eagerly await feedback from the teacher in order to enhance our performance
We sincerely thank you!
Trang 4THE PROJECT WAS COMPLETED
AT TON DUC THANG UNIVERSITY
I pledge that this is a product of our own project and is under the guidance of
Mr Phạm Thái Kỳ Trung The content of research, results in this subject is honest and not published in any form before The data in the tables used for the analysis, comment, and evaluation were collected by the authors themselves from various sources indicated
in the reference section
In addition, many comments and assessments as well as data from other authors and organizations have been used in the project, with references and annotations
If any fraud is found, I am fully responsible for the content of my project.
Ton Duc Thang University is not involved in any copyright infringement or copyright infringement in the course of implementation (if any)
Ho Chi Minh, July 20 2021 th Author (sign and write full name)
Huynh Nhat Nam
Trang 5EVALUATION OF INSTRUCTING LECTURER
Confirmation of the instructor
_ _ _ _ _ _ _
Ho Chi Minh City, 2021 (sign and write full name)
The assessment of the teacher marked
_ _ _ _ _ _ _
Ho Chi Minh City, 2021
Trang 6TABLE OF CONTENT
ACKNOWLEDGEMENT i
THE PROJECT WAS COMPLETED AT TON DUC THANG UNIVERSITY ii
EVALUATION OF INSTRUCTING LECTURER iii
TABLE OF CONTENT 1
LIST OF TABLES, FIGURES, GRAPHS 2
EXECUTIVE SUMMARY 3
CHAPTER 1: INTRODUCTION 4
1 Encryption and decryption 4
2 Symmetric and asymetric cryptosystem 4
CHAPTER 2: MONOALPHABETIC SUBSTITUTION CIPHERS 5
1 Monoalphabetic Substitution Cipher 5
CHAPTER 3: FREQUENCY ANALYSIS 6
1 Frequency analysis 6
CHAPTER 4: EXPERIMENTS 8
1 Encryption Function 8
REFERENCES 10
Trang 7LIST OF TABLES, FIGURES, GRAPHS
Figure 1: Types of substitution ciphers 5
Figure 2: Relative frequency of letters in the English alphabet 7
Figure 3: Encryption with 100 words 9
Figure 4: Encryption with 1000 words 9
Trang 8EXECUTIVE SUMMARY
The following essay is divided into four chapters The first chapter will cover encryption and decryption The second chapter will discuss the Monoalphabetic Substitution Cipher encryption method, including how it works, limitations, and advantages Chapter 3 will cover Frequency Analysis, a method used to decode, just as Chapter 2 will cover how it works, limitations, and advantages Finally, chapter 4 will
be the part where I encrypt and decrypt the text; I will experiment with different lengths of text to make comparisons and comments
Trang 9CHAPTER 1: INTRODUCTION
1 Encryption and decryption
Encryption is the process of converting plaintext data into something that appears random and meaningless (ciphertext) The process of converting ciphertext back to plaintext is known as decryption Symmetric encryption is used to encrypt more than a small amount of data During both the encryption and decryption processes, a symmetric key is used The key that was used to encrypt the data must be used to decrypt a specific piece of ciphertext Every encryption algorithm seeks to make it as difficult as possible to decrypt the generated ciphertext without the use of the key There is no technique that is significantly better than methodically trying every possible key if a really good encryption algorithm is used The longer the key for such
an algorithm, the more difficult it is to decrypt a piece of ciphertext without the key
The quality of an encryption algorithm is difficult to assess Algorithms that appear
to be promising can sometimes be very easy to break if the proper attack is used When choosing an encryption algorithm, it's best to go with one that's been in use for a while and has successfully resisted all attacks
2 Symmetric and asymetric cryptosystem
Symmetric encryption entails using the same key for both encryption and decryption The plaintext, along with a key, is fed into an encryption algorithm The key collaborates with the algorithm to convert plaintext to ciphertext, thereby encrypting the original sensitive data This is useful for storing data that will need to be decrypted at a later time The use of a single key for both encryption and decryption reveals a problem, as a compromise of the key would result in a compromise of any data encrypted by the key This is also ineffective for data-in-motion, which is where asymmetric encryption comes into play
Trang 10Asymmetric encryption works with a pair of keys The beginning of asymmetric encryption involves the creation of a pair of keys, one of which is a public key, and the other which is a private key The public key is accessible by anyone, while the private key must be kept a secret from everyone but the creator of the key This is because encryption occurs with the public key, while decryption occurs with the private key The recipient of the sensitive data will provide the sender with their public key, which will be used to encrypt the data This ensures that only the recipient can decrypt the data, with their own private key
So, Asymmetric encryption will be preferable, but we will make different decisions depending on which case uses the best algorithm to optimize
CHAPTER 2: MONOALPHABETIC SUBSTITUTION
CIPHERS
1 Monoalphabetic Substitution Cipher
A mono-alphabetic substitution cipher is a type of substitution cipher in which the same plaintext letters are replaced by the same ciphertext letters The term "mono," which means "one," denotes that each letter of the plaintext has a single ciphertext substitute Multiple substitutions are made in the ciphertext to correspond to the letters
in the plaintext in a poly-alphabetic substitution cipher
Trang 11Figure 1: Types of substitution ciphers
Example:
Enciplers to : “ VA VFII ILPQ”
In my opinion, there are numerous monoalphabetic substitution ciphers, in fact an infinite number, because each letter can be encrypted to any symbol, not just another letter Simple substitution ciphers can be traced back to the earliest civilizations, and they were more than adequate for the purposes for which they were required for a long time They are extremely weak and easy to break by today's standards, but they were an important step in the development of cryptography
CHAPTER 3: FREQUENCY ANALYSIS
1 Frequency analysis
The study of the frequency of letters in the ciphertext is known as frequency analysis The basic idea behind frequency analysis is to count the frequency of ciphertext letters and then associate them with guessed plaintext letters The presence
of more Xs in the ciphertext than any other character suggests that X corresponds to e
in the plaintext, but this is not certain; t and an are also very common in English, so X could be either of them as well It is unlikely that it is a plaintext z or q, which are less common As a result, the cryptanalyst may need to experiment with various mappings between ciphertext and plaintext letters
Plaintext alphabet ABCDEFGHIJKLMNOPQRSTUVWXYZ
Ciphertext alphabet ZEBRASCDFGHIJKLMNOPQTUVWXY
Trang 12Figure 2: Relative frequency of letters in the English alphabet
Following example to help better understand this algorithm:
Text:“MKLAJZHAIUQWKHJABZNXBVHAGKFASDFGALQPIWRYIOQYWIER MASVZMNBZXCKJASDFGLKJFHWQERYIOQWTYIOASUDYFLASKJDHFZMZ VBCXMVQLWERYIQRASDFQIWUERYIHKMFMAKHLSDFYUIOQWYREIORY IWQEUFHAKDFHLKASHFKVBBBNASMDFSADFWQEUYRUUEYRUUUQKAS JHFKJDSHFSNBNBNBNBABABAAASKJFHLKJSADHFIDUASFOYDASIYFQW ERBQWBRKLJLKASSADFDFDASDA”
Using the algorithm, I discovered that the two letters with the highest frequency are A (58 occurrences) and T (2 occurrences) This means that A is an E after decoding, and T can be Z, X, Q, or J As I previously stated, depending on the length of the code, this algorithm may miss a few characters However, in language, if a few letters are incorrect, we can still read and predict
In my opinion, This algorithm, in my opinion, is extremely simple to implement Although it is difficult to decode short text, it is still effective to decode long text
CHAPTER 4: EXPERIMENTS
Trang 131 Encryption Function
Code explanation:
Step 1: Import the necessary modules
Step 2: Create a set of randomly generated numbers and the alphabets that correspond to those numbers (Table previously created)
Step 3: Create a function that allows us to generate an inverse on the same function using a single phase cipher
Step 4: Write a function to perform the encryption and decryption functions of a Monoalphabetic substitution cipher We will now concentrate on the Python implementation of a monoalphabetic cipher The key used for encryption is as follows:
abcdefghijklmnopqrstuvwxyz CZQJRWYBUKHVLXMSNFEPIDGTOA
# Encryption using Monoalphabetic substitution Cipher
import string
key = " CZQJRWYBUKHVLXMSNFEPIDGTOA "
plaintext = “my favorite is swimming"
cipher = ""
for c plaintext: in
c string.ascii_lowercase: if in
index = ord (c) - ord ( ' a ' )
cipher cipher key[index] = +
else :
cipher cipher c = +
print ( Plaintext alphabet: " + plaintext)
print ( " " )
print ( Ciphertext alphabet: " + cipher)
The following I will run with different cases that are paragraphs of different lengths:
Trang 14Figure 3: Encryption with 100 words.
Figure 4: Encryption with 1000 words
Trang 15Link: