VIETNAM GENERAL CONFEDERATION OF LABOR TON DUC THANG UNIVERSITY FACULTY OF INFORMATION TECHNOLOGY THE MIDTERM OF PROBABILITIES AND STATISTICS RESEARCH ON ENCRYPTION AND DECRYPTION In
Trang 1VIETNAM GENERAL CONFEDERATION OF LABOR
TON DUC THANG UNIVERSITY FACULTY OF INFORMATION TECHNOLOGY
THE MIDTERM OF PROBABILITIES AND STATISTICS
RESEARCH ON ENCRYPTION AND
Trang 2VIETNAM GENERAL CONFEDERATION OF LABOR
TON DUC THANG UNIVERSITY FACULTY OF INFORMATION TECHNOLOGY
THE MIDTERM OF PROBABILITIES AND STATISTICS
RESEARCH ON ENCRYPTION AND
DECRYPTION
Instructor: MR.NGUYỄN QUỐC BÌNH
Student: MAI BẢO THẠCH – 520H0490
Class: 20H50304
Course: 24
Trang 3THANKFUL WORD
After working for a half semester with the enthusiastic help and support of Mr Nguyễn Quốc Bình, I was able to complete the report in the most complete and effective way His teaching has given our students a lot of knowledge as well as full skills in the specialized subject Although couple of months is quite short, but that time has also helped me to easily approach the major step by step with a solid foundation, especially with the encouragement and help from seasoned lecturers
I sincerely thank
Trang 4REPORT COMPLETED AT TON DUC THANG
UNIVERSITY
I hereby declare that this is my own report and is under the guidance of Mr Nguyễn Quốc B The research contents and results in this topic are honest and have not been published in any form before The data in the tables for analysis, comments and evaluation are collected by the author himself from different sources, clearly stated in the reference section
In addition, the project also uses a number of comments, assessments as well
as data of other authors, other agencies and organizations, with citations and source annotations
If I find any fraud I take full responsibility for the content of my report
Ton Duc Thang University is not related to copyright and copyright violations caused
by me during the implementation process (if any)
Ho Chi Minh city, 09 April, 2022
Author (sign and write full name)
Mai Bảo Thạch
Trang 5TEACHER’S CONFIRMATION AND ASSESSMENT
SECTION
Confirmation section of the instructors
_ _ _ _ _ _ _
Ho Chi Minh city, day month year (sign and write full name)
The evaluation part of the lecturer marks the report
_ _ _ _ _ _ _
Trang 7TABLE OF CONTENTS
THANKFUL WORD 3
REPORT COMPLETED AT TON DUC THANG UNIVERSITY 4
TEACHER’S CONFIRMATION AND ASSESSMENT SECTION 5
SUMMARY 6
TABLE OF CONTENTS 7
LIST OF ABBREVIATION 9
LIST OF DIAGRAMS, CHARTS AND TABLES 10
CHAPTER 1: INTRODUCTION 12
1.1 Encryption: 12
1.2 Decryption: 13
1.3 Symmetric: 14
1.4 Asymmetric Cryptosystem: 15
CHAPTER 2: MONOALPHABETICAL SUBSTITUTION CIPHER 18
2.1 Definiton of substitution cipher: 18
2.2 State the problem: 18
2.3 Idea of solution and algorithm: 19
2.4 Example and evaluation with analysis: 19
CHAPTER 3: FREQUENCY ANALYSIS 22
3.1 Definition of Frequency Analysis: 22
3.2 State the problem: 23
3.3 Idea of solution and algorithm: 23
Trang 8CHAPTER 4: EXPERIMENTS ON PYTHON 26
4.1 Experiments on Encryption: 26
4.2 Experiment on Decryption: 38
REFERENCES 45
APPENDIX 46
Trang 9LIST OF ABBREVIATION
AES: Advanced Encryption Standard
Trang 10LIST OF DIAGRAMS, CHARTS AND TABLES
Picture 1 Asymmetric 17
Picture 2 Encryption 17
Picture 3 Symmetric 17
Picture 4 Example of cipher keys 19
Picture 5 Monoalphabetic Substitution Cipher Illustration 21
Picture 6 Frequency table 22
Picture 7 Values for Encryption 26
Picture 8 Source code of Encryption algorithm 27
Picture 9 Validation of letters 28
Picture 10 Algorithm 29
Picture 11 Importing testcases 30
Picture 12 Generated cipher keys 1 30
Picture 13 Testcase 1 30
Picture 14 Testcase 2 31
Picture 15 Generated cipher keys 2 31
Picture 16 Testcase 3 33
Picture 17 Generated cipher keys 3 33
Picture 18 Testcase 4 35
Picture 19 Generated cipher keys 4 36
Picture 20 Frequency table in Python Error! Bookmark not defined Picture 21 Import from input values file 38
Picture 22 Source code for Decryption algorithm 39
Picture 23 Code of checking existing 40
Picture 24 Code of alpha-beta sorting 41
Trang 11Picture 26 Testcase 43
Trang 12The process is operate like this:
Sender - Plain text – Encrypt – Transfer Decrypt Authorized users – –
Moreover encryption is a crucial part for any individuals or organizations to prevent hacker from robbing their sensitive information or code
Here is the example:
When a bank want to deliver someone9s credit card and their account numbers, those information need to encrypt in order to reduce the possibility of theft The way
to encrypt and its application and experiments are called as cryptography
How it works ?
The research given that the encryption strength depends a lot on the length of the security key In 20 century, the first length that developer use is 40-bit encryption th
with 2 possible permuations and 56-bit format But now on, the hackers are so 40
powerful and can break the defense of these formats through brute-force attack easily, this led to 128 bit-system becoming the standard of encryption9s length
Trang 13For instance, The Advanced Encryption Standard, which stand for AES, is a convention for information encryption made in 2001 by the U.S Public Institute of Standards and Technology AES utilizes a 128-digit block size, and key lengths of
Encryption makes it more challenging for an organization to break down its own information utilizing either standard means or man-made brainpower What's more, having the option to investigate information rapidly can now and then mean the distinction between which of two contending organizations acquires a market advantage; this part of the way makes sense of why organizations oppose encoding information
1.2 Decryption:
What is Decryption ?
This concept is the reverse of above Encryption This is a Cypher Security format that make hacker or thief inconvenient in finding a chance to steal the information when they are not allowed to read these datas It tranforms the cipher text into the original text that people with decryption keys can easily read it and understand throughout some tools This techniques required some coding function to make it
Trang 14unreadable However, we already know that Encryption protects data but the accesser must have the authorized tools to reach the plain data this means the Decryption can
be done manually or using decode application
What are the types of Decryption ?
In this concept, I will introduce just a few type of decryption such as AES About AES, it is exceptionally effective in 128-cycle structure, and AES likewise uses 192 and 256-bit keys for substantial information encryption AES is by and large accepted to be impervious to all assaults, barring savage power, which attempts to decipher messages utilizing all potential blends of 128, 192, or 256-cycle cryptosystems In any case, Cyber Security experts guarantee that AES will at last be hailed as an accepted norm for information encryption in the private area
What is the advantage of Decryption ?
There are many purpose on utilizing Decryption but the main course still is the fresh and unbreakable organization supervision This method help Cipher Security in the whole new levels of protect information as it reduce the amount and the percentage
of confusion in reading and understanding the datas
What is the process of Decryption ?
The data or information or cipher text will be delivered to the receiver After that, it is enable to convert from random code or keys into the original form of the datas
1.3 Symmetric:
The least complex method for demonstrating likelihood of a framework is through balance For instance the idea of a "fair" coin implies there are two potential
Trang 15results that are undefined Since each outcome is similarly possible the result is 50/50 heads or tails
Comparatively for a fair kick the bucket there are 6 potential results, that are largely similarly reasonable This implies they each have the likelihood 1/6
The possibility of balance is behind arbitrary inspecting If we have any desire
to comprehend a populace we can take various arbitrary cases and it educates us something concerning the entirety Anyway this is possibly evident assuming the example is irregular as for the properties we're estimating That is assuming we traded individuals haphazardly we would probably gauge them
Another model is a spinner, similar to a roulette wheel The model is that a fair twist is similarly liable to land anyplace on the periphery circle So by evenness the likelihood of a result is relative to the length of the curve it subtends on the circle This likewise is relative to the point of the curve, which is corresponding to the region
of the circular segment
What is asymmetric cryptography ?
This concept is known as cryptography format, which is utillize to pair a public key with a private data in order to encode and decode information and prevent hacker from robbing the access or sensitive data,
To understand more about public key, it is a cryptographic key which is used
to encrypt datas in order to decrypt by the receiver with their private key (private key
is only shared with the sender)
Trang 16There are a majority of protocols that depend on asymmetric cryptography which included the TLS (Transport layer security) and the SSL (Secure sockets layer) which makes HTTPs possible
The purpose of using asymmetric cryptography is increasing the information protection This technique does not require to publish the private keys when encrypting So that, we can protect our information and hold the these data outside those cybercriminal9s range
How does asymmetric cryptography work ?
Hilter kilter cryptography is regularly used to confirm information utilizing computerized marks A computerized mark is a numerical method used to approve the legitimacy and trustworthiness of a message, programming or advanced report It
is what might be compared to a written by hand signature or stepped seal
In light of uneven cryptography, advanced marks can give affirmations of proof to the beginning, character and status of an electronic archive, exchange or message, as well as recognize informed assent by the underwriter
What are examples of asymmetric cryptography ?
The RSA calculation - - the most generally utilized unbalanced calculation - -
is installed in the SSL/TLS, which is utilized to give secure interchanges over a PC organization RSA gets its security from the computational trouble of figuring huge numbers that are the result of two enormous indivisible numbers
Duplicating two huge primes is simple, however the trouble of deciding the first numbers from the item - - calculating - - structures the premise of public-key cryptography security The time it takes to factor the result of two adequately huge primes is past the abilities of most assailants
Trang 17RSA keys are ordinarily 1024 or 2048 pieces in length, yet specialists accept 1024-cycle keys will be broken soon, which is the reason government and industry are moving to a base key length of 2048-bits
Picture 2 Encryption
Picture 3 Symmetric
Picture 1 Asymmetric
Trang 18CHAPTER 2: MONOALPHABETICAL SUBSTITUTION
CIPHER
2.1 Definiton of substitution cipher:
A replacement figure is a sort of encryption where characters or units of text are supplanted by others to encode a text arrangement Replacement figures are a piece
of early cryptography, originating before the advancement of PCs, and are presently somewhat old
In a replacement figure, a letter like An or T, is rendered into another letter, which actually encodes the grouping to a human peruser The issue is that basic replacement figures don't actually encode successfully regarding PC assessment - with the ascent
of the PC, replacement figures turned out to be generally simple for PCs to break Nonetheless, a portion of the thoughts behind the replacement figure keep on living
on - a few types of present day encryption could utilize a very enormous message set and an incredibly complex replacement to encode data really
2.2 State the problem:
Our requirement is using monoalphabetical substitution cipher algorithm to encode a plaintext into some scripts that the hackers or thief can not reach it easily But the case
we will focus in is English alphabet and with the length about 50 words to 5000 words depending on what testcase we need
Moreover, the condition here is we need to use distinct character and replace separately that mean a letter will be replaced exactly one specified letter, no exception here
The monoalphabetical substitution cipher algorithm are born to do that, it will receive original text and transfer it into cipher text which means the code that not everyone
Trang 19in the alphabet which means we need to generate the cipher alphabet before execute the algorithm
When you generate 8a9 will be replaced by 8r9 which means every time 8a9 appears in the plaintext, it will change into 8r9 The cipher alphabet will be generate again when use to encode another script not the old one which means it will have a permutation
of cipher alphabet when you want to encode a new script
2.3 Idea of solution and algorithm:
My idea is to solve and replace the letter in their lowercase format so it will be easier
to solve when uppercase appear making it compatible for all letter in plaintext
About the cipher alphabet, it will be generate randomly when encoding a new script (default, we will have 26 factorial of position in cipher alphabet)
In above table, we see that each default alphabet is fixed with a letter in the alphabet and just will be replaced by it as long as in the same script we use not the new one The idea is using list to contain default alphabet and then fixed the alphabet with cipher alphabet to maintain each letter fixed with the key letter in cipher As the result, after replace respectively each letter with key using loop
2.4 Example and evaluation with analysis:
Given the string script of Ielts reading passage below and encode it with random cipher alphabet:
<Not many people have mental imagery as vibrant as Lauren or as blank as Niel They are the two extremes of visualisation Adam Zeman, a professor of cognitive and
Picture 4 Example of cipher keys
Trang 20aphantasia and its polar-opposite hyperphantasia His team, based at the University of Exeter, coined the term aphantasia this year in a study in the journal Cortex =
With the support of the cipher alphabet fixed letter it will tranform into this:
<lih nvlp cuicsu rvtu nulhvs anvyugp vb taxgvlh vb svzgul ig vb xsvlo vb laus hrup vgu hru hwi uehgunub id tabzvsabvhail vmvn kunvl, v cgidubbig id qiylahatu vlm xurvtaizgvs luzgisiyp, wvlhb hi qincvgu hru satub vlm uecugaulqub id cuicsu wahr vcrvlhvbav vlm ahb cisvg-iccibahu rpcugcrvlhvbav rab huvn, xvbum vh hru zlatugbahp id ueuhug, qialum hru hugn vcrvlhvbav hrab puvg al v bhzmp al hru jizglvs qighue =
Note that all commas, dot or dash will be maintain as it original forms
We can notice that the way using monoalphabetical substitution cipher is very simple cause you just need to replace one by one letter with your generated key table (just another letters without any special symbols) This lead to a lot of secure problems because it is very easy to break it throughout some methods Such as, Frequency analysis use the amount of appearance of a letter to construct a table tell that whichthe frequency for that letter being encoded In English (and different dialects) there's an immense variety in how continuous various letters show up "e" is the most widely recognized one, representing around 13% of all letters in a message, next is "t" at 9%
"a" at 8% thus on.[1] To figure out the code, I just count how often each letter shows
up in the ciphertext, and afterward I surmise that the letter that shows up most often
is an "e", the second most successive one is a "t, etc Subsequent to having done this for a portion of the letters, it becomes conceivable to perceive words, on the off chance that for instance "t?e" shows up habitually, the ? is probably going to be a "h" - for each new letter I accurately surmise, speculating the leftover ones becomes more straightforward and pretty soon the code is broken
Trang 21For instance, The Advanced Encryption Standard, which stand for AES, is a convention for information encryption made in 2001 by the U.S Public Institute of Standards and Technology AES utilizes a 128-digit block size, and key lengths of
128, 192, and 256 pieces
In the present day, people use 128-format as standard However, most banks, militaries organizations and governements prefer using 256-bit long term
Example of Encryption ?
Trang 22distinction between which of two contending organizations acquires a market advantage; this part of the way makes sense of why organizations oppose encoding information
What is Decryption ?
This concept is the reverse of above Encryption This is a Cypher Security format that make hacker or thief inconvenient in finding a chance to steal the information when they are not allowed to read these datas It tranforms the cipher text into the original text that people with decryption keys can easily read it and understand throughout some tools This techniques required some coding function to make it
Trang 23unreadable However, we already know that Encryption protects data but the accesser must have the authorized tools to reach the plain data this means the Decryption can
be done manually or using decode application
What are the types of Decryption ?
In this concept, I will introduce just a few type of decryption such as AES About AES, it is exceptionally effective in 128-cycle structure, and AES likewise uses 192 and 256-bit keys for substantial information encryption AES is by and large accepted to be impervious to all assaults, barring savage power, which attempts to decipher messages utilizing all potential blends of 128, 192, or 256-cycle cryptosystems In any case, Cyber Security experts guarantee that AES will at last be hailed as an accepted norm for information encryption in the private area
What is the advantage of Decryption ?
There are many purpose on utilizing Decryption but the main course still is the fresh and unbreakable organization supervision This method help Cipher Security in the whole new levels of protect information as it reduce the amount and the percentage