The Mathematics Behind Some Types of Cryptography

Cryptography actually has quite a bit of basis from mathematics. Different types of mathematics are used in order to understand and decrypt particular ciphers and this page is to guide users through the process of solving for different types of ciphers. This page will explain a few methods involved with frequency analysis along with a couple of ciphers. This page will discuss, specifically, affine ciphers and additive ciphers (otherwise known as Shift ciphers).

Frequency analysis (with respect to cryptography) involves analyzing the frequency of letter distribution within coded messages. Many of the basic types of ciphers can be cracked using the method of Frequency analysis. It is used in that it analyzes the frequency certain letters are appearing in a coded message and determines which original letter is being represented by the coded letter. For an example, look at the following message below:

ymj rtxy nrutwyfsy ymnsl yt wjrjrgjw bmjs btwpnsl bnym hwduytlwfumd fsi kwjvzjshd fsfqdxnx nx yt wjrjrgjw bmnhm qjyyjw nx zxji rtxy tkyjs.

One can count up the number of each letter from this message. After doing so, we see that j is the most common letter in the message. We can reference the graph below to help us out. This graph shows the frequency of each letter taken from a random sample of 40,000 words. Using this graph can help use crack the code and decrypt the message that is written above.

The process of frequency analysis generally works for these types of ciphers. The process gets more and more difficult and less effective with smaller messages. Meaning, the larger the message (and the more letters involved) the more likely it is for one to decrypt the message because of the more letters involved with the longer message. This is a neat relation to mathematics because a lot of mathematics (and statistics) focuses on the analysis of certain behaviors or things. A big field of study that requires analysis is Data Science. This type of job requires much analysis of different types of data of all sorts. Other areas of math deal with analysis when working with problem solving because the analysis of data and other information allows one to see and determine what is and is not relevant.

One cipher that I want to tackle right now is the additive cipher (or shift cipher) . These guys are quite applicable to mathematics, particularly linear equations! Additive ciphers can be written in the form of a linear equation like Y=X+A where X is the number corresponding to our plain text letter, Y is the number corresponding to our cipher text letter and A is the shift that is taking place in the message. Look at the following message:

Gjjozobk iovnkxy gxk tuz zuu ngxj zu yurbk gtj eua igt ayk gt gvvrkz zu yurbk oztd.

We could try to shift the cipher by hand to see if the message makes sense. As we are going through the various shifts, once we get to the shift where A=6, we the decrypted message:

Additive ciphers are not too hard to solve and you can use an applet to solve them.

Below is an applet that we can use to help solve the encrypted message above. Feel free to mess around with the applet and try to encode and decode your messages!

Unfortunately, a shift cipher happens to be one of the ciphers that can be easily broken by frequency analysis. So how about we look into a different cipher which is called the Affine Cipher.

This type of cipher is similar to the shift cipher; however, it incorporates some multiplication as well. The equation associated with this cipher takes the form of Y=AX+B. X still represents the number corresponding to our plain text letter and Y is the number that corresponds to our cipher text letter. This difference here is that B is now any number that ranges from 0-26 and A is any number that is coprime to 26. If A is not coprime to 26, then the cipher will not work because multiple plain text letters will be encoded with the same cipher text letter, which causes for much confusion. One has to remember that all of the ciphers used are all in modulo 26 due to the number of letters in the English alphabet.

Feel free to head on to the next page talking about the significance of cryptography in this day and age!