3
$\begingroup$

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?

$\endgroup$
1

1 Answer 1

4
$\begingroup$

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.

$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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