Cryptography Stack Exchange is a question and answer site for software developers, mathematicians and others interested in cryptography. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am writing a program which will use Chi-Square to determine which is the correct keyword for a ciphertext via Vigenère cipher.

I came across a website that describes the Chi-Square statistics in a rather simplistic manner and had also written some code to achieve my goals. However, the actual keyword does not seem to be the lowest chi-square value as according to the website. I'm not sure if the method as describe is correct or not.

Quoting the website:

Chi-squared Statistic

The Chi-squared Statistic is a measure of how similar two categorical probability distributions are. If the two distributions are identical, the chi-squared statistic is 0, if the distributions are very different, some higher number will result. The formula for the chi-squared statistic is:

chi-square formula

where CA is the count (not the probability) of letter A, and EA is the expected count of letter A.

This page will describe the use of the chi-squared statistic for cryptanalysis. Ordinarily, statisticians use the chi-squared statistic for measuring the goodness of fit of data. Unlike statisticians, we make no assumptions about the distribution of our data, and draw no conclusions about the significance of the result. We simply use the method to suggest a possible decryption.

Would someone be able to provide some advice on this?

share|improve this question

This method isn't deterministic. That is, just because a keyword has the lowest chi-square value, that doesn't mean it's the keyword. All it means that there is a good chance that it is the keyword. It's not a guarantee. You should look at the first several likely options to see if the keyword lies there. If you want to automate this, you could compare the possible keywords against known words using some dictionary file.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.