So, I have been assigned an assignment where I had to solve a Vigenere cipher.

Following along with this webpage I managed to get all the way to the chi-squared step. But, that is the problem. Upon trying to code this, I found my results to be unfavorable. In fact, all of my results for the chi-squared probability test for each string were exactly the same. So, obviously I did it wrong.

I tried to use the formula on this page to calculate this for each character, and for each string, I added them all together. Doing this leads to them all being the same total number for each string, which makes sense. But, if that is the case, how exactly do I use it to solve the cipher?

What I did:

  • Found the key length with I.O.C. (say it's 7)
  • Create a string of all the 7th characters and the 1st
  • Write a method to calculate chi squared value
  • Calculate this for each character in each string from A-Z
  • For each string, add up the probability of all the letters(PROBLEM)

What exactly am I supposed to do here? All of my "chi-squared" results are the same.

P.S. I found the keyword using a codebreaking website to clarify that my other information was right, but I would really like how do solve this last step.