Skip to content

An autocorrelation function for the cryptanalysis of the Vigenere cipher used to determine the length of an encryption key.

License

Notifications You must be signed in to change notification settings

sean-leichtle/Autocorrelation

Repository files navigation

Autocorrelation

This repository is didactic in nature1 and provides a simple autocorrelation function for the cryptanalysis of the Vigenere cipher. It may be used, specifically, to determine the length of the key used to encrypt a ciphertext. With respect to the number of matching characters per shift of a copy of the ciphertext as compared to the ciphertext itself, any periodic interval occurring between maxima is indicative of key length.

Autocorrelation has some advantages over other popular means of determining key length. Unlike the Kasiski Test, it does not depend upon recurring n-grams, and the implementation is simpler than that of the Friedman Test.

Both Java and Python implementations are included.

Java

The Autocorrelation class can be used to output the number of matching characters per shift of ciphertext to the console while the AutocorrelationVisual class displays the same information as a JavaFX line chart.

In the latter case, to avoid employing a build system (e.g. maven or gradle) or the somewhat involved process of compiling from the command line, the use of Java 1.8 or "Java 8" or a more recent Azul JDK, both both of which come packaged with JavaFX, is recommended. The implementation requires user input for the ciphertext and desired number of shifts in the first two statements of the main()-method:

  • String ciphertext = "/* Insert ciphertext here */";
  • int shifts = /* Insert desired number of shifts here */;

Python

autocorrfuncs.py contains a series of functions for analysis via autocorrelation, while autocorrelation.py includes an object-oriented implementation of the same. Both versions allow for the output of results to the console or as a line chart.

Footnotes

  1. Accompanying material (in German) may be found at https://abz.inf.ethz.ch/unterrichtsmaterialien/28259-2/.

About

An autocorrelation function for the cryptanalysis of the Vigenere cipher used to determine the length of an encryption key.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published