Blaise de Vigenère

Understanding the Anagram or Permutation Cipher

An Affine Cipher is akin to a Vigenère Cipher where a Linear Congruential Sequence (LCS) replaces the key word. It is generated by selecting four integers a, b, m and a seed (x0)and letting xn+1=(a*xn+b) mod m   The result is than applied as an ASCII shift to the nth character in the text. In essence, the LCS is the equivalent of a very long keyword and is considered a pseudo-random number sequence.

To run the demo below, first enter a plain text manually, or select a sample plain text.  Then enter four integers that will be used to generate the LCS sequence.  If you wish, you may check the box to generate random LCS values.  Ensure that "Encrypt" radio button is selected.  Then hit "Execute".  There may be a short delay as the output is produced. If you wish to decrypt the result, highlight the "Decrypt" radio button and hit "Execute".  Do not change the LCS values, or the cipher text will not properly decrypt.  If you wish to see other data that is generated by this page, you may select from the menu below each data field.

Two plots will appear below the results.  This output is explained below the plots.


Enter Text  Manually Romeo & Juliet Prolog  Gettysburg Address Mark Antony's Eulogy            



Enter Permutation Vector  1 2 3 4 5 6 7 8 9 10   Apply Shift  

(Enter Integers from 1 through 10. The first zero will be considered the end of the vector.)


Or Generate Random Permutation Vector of Length          Encrypt    Decrypt    






Histogram of LCS (mod 94) Values

The plot displays the number of times shift values occurs in the LCS sequence.  The yellow line is the length of the text divided by the number of ASCII characters (94) rounded up to the next integers.  Optimally, the histogram should contain all values and the bars should be at or below the yellow line. 

LCS (mod 94) Plot

This figure is created by plotting pairs of values from the LCS sequence until a repetition occurs. It provides a visual measure of the "randomness" of the sequence.   Many points and a lack of order among those points indicates a higher degree of randomness.  Few points indicate that the LCS quickly entered into a loop.

Histogram of Cipher Text

The histrogram indicates that the plain text has been diffused over the entire ASCII spectrum.  In a perfect cipher, all bars would be at or below this line.

Return to Cryptography Page

Hit Counter