Vigènere Ciphers


For the first time in a while, I had a coding assignment for computer science — to code a program that would encrypt a message using the Vigènere cipher. If you don’t know what that is, here is a short description:

Pick a message to encode. This time I’ll use, “Friend, at exactly seven tonight we must launch an attack on the enemy so we can win the larger war ahead of us. Additionally, if possible …”. Then pick a keyword – for this case I’ll use “lemon”. The phrase is then transformed into a series of the keywords, for this case “lemonl, em onlemon …” Then the message is shifted according to that keyword and the original letters of the phrase, transforming the text into the encrypted “Qvusao, ef sklgfzl dihsa eszwtsx is zfwf znfrov ny efhnno ab gsi qbrxc ec jp gmb jtr fvr wedurc amf…”

While this itself is not hard, the challenge emerges when you don’t know the keyword and need to work backward. This was the optional assignment portion of the lab, but I was interested and ended up making something to solve the majority of it. Essentially, the program I wrote does the opposite, and is given solely the encoded text. It tries to deduce the keyword and original message.

While this can be achieved by checking every word in the dictionary and comparing their encoded messages with the original, it takes way too long. So, I utilized the Kasaski examination technique and a frequency analysis for words in the English language. The Kasaski examination was from this guy named Kasaski and he figured out a way to determine the most likely length of the keyword solely from the cipher text. To be honest, I don’t have the best understanding of it still and ChatGPT came in useful here. Then, a frequency analysis program uses the frequency that letters appear in English to reverse check the letters in the encoded message itself and return a list of the most possible letter combinations.

Once this series of letter combinations for the cipher are found, I then use a detect English and a dictionary to check the similarity of the likely possible words, and then brute force run them through the generic algorithm. Overall, this allows the program to work far faster and more efficiently when dealing with encryption keys that are in the dictionary. This arises one of the two major problems with the program, and why I still classify it as a “work in progress”, which will only work for keywords in the English Dictionary. Meaning that if I were to encode the saying with my name, PerrinRoot, my program would not work.

Additionally, the program struggles with scaling downward, and that is the larger percentage of the phrase the keyword is (or the fewer times it is repeated), the slower the program can find the keyword. It will eventually, but that eventually may be after searching through nearly the entire dictionary.

Here is a little demonstration which demonstrates its speed when the phrase is long enough (this is not speed up):

Volunteering


On top of the coding, this past week I also did a lot of volunteering. On Saturday, I helped for 5 hours at the WIN tournament, which is a local soccer non-profit tournament. I arrived early and was stationed at the basketball court, which is for 9- and 10-year old games. Looking back, I am happy I got indoors because everyone else is doing my position and was stationed outside.

People in Westport, however, are crazy about their soccer. After each game, there would be at least one parent who would come up to the center table and complain to the ref or me (I was timing and scoring the games). I remember that after the second game, this woman came up to me and told me I had ended the game early by 10 seconds, as if that would have made any difference. Also, if anything, I had given them more time because I stopped the clock when this one kid was injured — something I was specifically instructed not to do.

The next day, I went back to the same place and volunteered at a local school play. This was a far better and more enjoyable experience because it consisted of selling overpriced candy to kids. They had overbooked the number of volunteers, so I just ended up talking with a friend more most of the time instead of doing something.

Leave a Reply

Your email address will not be published. Required fields are marked *