How you can use programming to crack old historical ciphers

I will be making a program that will be able to crack old codes and comparing them to how they would have cracked them back then.
Grade 9

Presentation

No video provided

Problem

The problem that I was trying to solve in my project is, can computer code be used to crack historical ciphers? I will attempt to solve this problem via coding a program that will crack a variety of ciphers.

Method

The first code that I cracked was the Caesar cypher. This caode was very simple; it worked by shifting the values of each letter by an integer. The method I used to solve this was brute force. By shifting the values of one letter at a time and comparing them to a dictionary of English words, the correct message was decoded. The whole process would take around 0.16 seconds; this is because of my computer's capabilities.

The second code was much more complex and required a frequency analysis to crack it. By looking at how many times each letter is used in the English dictionary, you could replace the most used letters in the encrypted text with the most used in the dictionary. Through lots of trial and error, I managed to get to a point where it was much easier to read the text.

Analysis

Program one Cesar cipher:

Out of the two programmes I completed, this one was the least complicated. To obtain the scrambled value, I had to first create a programme that would read in a text file and shift every value. Once I had the scrambled text file, I would run it through a programme that would brute force each shift value and look them up in a dictionary, ensuring it had the correct value and all the letters were found in the dictionary. To do this whole process it took around 0.16 seconds, and the code is relatively simple.

 

Program two randomized Cesar cipher/transposition cipher:

This code was much harder. Instead of shifting letter values to scramble, we randomised the mapping of each letter, which would mean there are over 4.0329146e+26 combinations for keys. Brut forcing this code did not work because of the fact that it would overload my computer memory, which took a very long time. Looking at other ways of solving it, I found out about the way that they used to solve it back in the day. Frequency analysis was how they used to solve it; by replacing the most used letters in a text with the most overall used in the English language, you would get a text that was somewhat close (e.g., e is the most used in the dictionary, for it is most likely what the most used letter in a text would be). By applying this method to my code, it would produce readable plain text (it is not perfect, but it took a lot of time to get it working).

Conclusion

In conclusion modern day computer code can be used to crack historical ciphers. It may very base on the complexity of the code, for example Caesar cipher was quite easy to crack with the program that I have made. The use of code and programs may also help with the cracking od future code as well.

Citations

souces:

  • Book of code- simon singh
  • https://en.wikipedia.org/wiki/Caesar_cipher
  • * https://www.khanacademy.org/computing/computer-science/cryptography/crypt/v/caesar-cipher
  • https://cryptii.com/pipes/caesar-cipher
  • https://en.wikipedia.org/wiki/Transposition_cipher#:~:text=In%20cryptography%2C%20a%20transposition%20cipher,without%20changing%20the%20characters%20themselves.

Using ChatGPT as a tool

Since I have never coded in Java, and my Dad (who helped me) has not coded in Java in many years, I used chatGPT to help me generate code.  I would provide ChatGPT will text description of functions I’d like to perform, and used the resulting response as code samples, which were altered and combined to create a new program.

Acknowledgement

I would like to thank my dad for helping me with the coding. At the start of this project, I knew nothing about java, now with the help of my dad I am a much better coder and can code simple java programs. I would also like to thank my teacher Ms. Bretner with help with the project side of thing; if I had question about science fair or how to do thing, she was always there to help me.