# Assignment | Computer Science homework help

[ad_1]

**Understanding the History of Encryption**

**Understanding the History of Encryption**

Few facts –

Encryption has been around for a very long time. Instead of explaining the History of Cryptography, I am going to recommend a very good book by David Khan called “The Code Breakers” , published in 1996.

Instead of starting with early encryption algorithm, I am going to used two interesting encryption algorithms that will capture manu of the concepts that Khan outline in his book. The first algorithm is Character Substitution. Remember, the problem we are trying to solve is “how do we secure communications?”. An example is – Suppose Alice and Bob wants to communicate securely using Eve is an attacker that wants to eavesdrop on the conversation. In order to communicate securely, Alice and Bob are going to share a secret key, which we are going to call K. Eve does not know anything about the key K.

Alice, Bob and even Eve know the algorithm (say character substitution). We all have played the substitution game in School. A is map to C and B is map to X and C is map to W and so on and so forth. So, if EVE gets the mapping and the ciphered text, she will be able to decipher the secret. Let supposed Eve gets the ciphered text but not the mapping (key). It will be difficult to figure the key out.

Assuming we have 26 letters, how many possibilities are there –> guess?

1. 26

2. 26X26

3. 26! (factorial)

4. 2^26

The answer is 26! which is about 2^88 if I remember correctly, which is a very large sample space. I hope you understand where I got the 26!. Think of one mapping and now think of another mapping and so on.

What is factorial? 1! = 1, 2! = 1X2 = 2, 3! = 1X2X3 = 6 and so on.

When I said 2^88, it is a good key since it is using 88 bits. Note that I am not saying it is great.

What I want you to do is to think about how you would break a substitution cipher? It is not hard but it needs some imagination.

**The Substitution Cipher and How to break the Cipher**

**Breaking The Substitution Cipher**

One way to break a substitution cipher is to use frequency analysis. Let’s focus on the English language for now but the process works the same way for other languages. The character “e” occurs 12.7% in the Eglish language and the letter “t” occurs 9.35% and the letter “a” is 8.2% of the time. So, you can count each character in the ciphered text, compute its frequency and start replacing it. After you complete the first say 4 characters, you may want to change your strategy. Can you explain why you want to stop after the first 4 characters? The two-character “of” is about 4.16% and “to” is about 2%. Now try three characters frequency.

After a period of time, you will be able to decipher most of the text. I am going to ask you to do your first significant homework using frequency analysis.

One possibility for the substitution cipher:

A

B

C

D

E

F

G

H

I

J

K

L

M

N

O

P

Q

R

S

T

U

V

W

X

Y

Z

↕

↕

↕

↕

↕

↕

↕

↕

↕

↕

↕

↕

↕

↕

↕

↕

↕

↕

↕

↕

↕

↕

↕

↕

↕

↕

V

J

Z

B

G

N

F

E

P

L

I

T

M

X

D

W

K

Q

U

C

R

Y

A

H

S

O

Note that we can have 25 factorial of these possibilities (remember 2^88 – 28-bit key)

**Here is your homework – A character sub was used. Can you decipher as much of this text as you can? Submit your results in the drop box below (Frequency Analysis). You may use Python to code the solution.**

**ztrfqvdjrzqt****rci wzyabi wdmwrzrdrzqt jzacif zw g jzacif rcgr cgw miit zt dwi hqf ygtx cdtvfivw qh xigfw (gt iojibbitr czwrqfx zw lzsit zt wzyqt wztlcw ‘rci jqvi mqqk’). zr mgwzjgbbx jqtwzwrw qh wdmwrzrdrztl isifx abgztrior jcgfgjrif hqf g vzhhifitr jzacifrior jcgfgjrif. zr vzhhifw hfqy rci jgiwgf jzacif zt rcgr rci jzacif gbacgmir zw tqr wzyabx rci gbacgmir wczhriv, zr zw jqyabiribx udymbiv.**

**rci wzyabi wdmwrzrdrzqt jzacif qhhifw sifx bzrrbi jqyydtzjgrzqt wijdfzrx, gtv zr pzbb mi wcqpt rcgr zr jgt mi igwzbx mfqkit isit mx cgtv, iwaijzgbbx gw rci yiwwgliw mijqyi bqtlif (yqfi rcgt wisifgb cdtvfiv jzacifrior jcgfgjrifw).**

**Understanding Vignere**

**Vignere Cipher**

Our follow on topic is Vignere Cipher which is an interesting algorithm developed by French Cryptographer Vignere. I will post more about the Vignere Cipher tomorrow and ways to hack the Vigenere cipher.

(You will run into different spelling of Vignere)

Vignere Cipher is a primitive Cipher and is not practical for the computing today but it uses an interesting substitution. There is something called Vignere table:

The Vignere cipher requires a key of fixed length. For our example we are going to use the word CRYPTO. Please do not worry about upper case and lower case.

The clear text we are going to encrypt is:

IT IS A GREAT DAY AT MARYMOUNT

What we do next is to paste the key below the clear text with all spaces removed.

ITISAGREATDAYATMARYMOUNT <————— Clear Text

**CRYPTO**CRYPTOCRYPTOCRYPT <————– Key

To encrypt the letter “I” in the message, you would look at row “I” and column “C” – the “C” in CRYPTO since they lined up. The result is “K”. Next, we move to the next character, which is a “T” for the row and an column “R”. I will let you complete the rest.

ITISAGREATDAYATMARYMOUNT <————— Clear Text

**CRYPTO**CRYPTOCRYPTOCRYPT <————– Key

KK <————– CIPHERED TEXT

Assume you know the length of the key, how would you break this encryption? Think about this question and come up with ideas and we’ll use next week discussion to post your findings