Substitution Cipher

Suggested experiment

  • Enter plaintext in the INPUT TEXT box.
  • Click NEW KEY to generate a random key.
  • Click ENCRYPT to encrypt with it.
  • Or click SECRET to have the computer do the above steps.
  • Click LETTER FREQUENCY to see how a guessed key gives ciphertext matching the distribution of english. Continue trying substitutions until they match.

    Overview

    The Simple Substitution Cipher is a generalization of the Shift Cipher and the Affine Cipher. The key consists of 26 letters in some particular order, which give the ciphertext for each possible plaintext character from "a" to "z". Click NEW KEY to generate a random key, and CLEAR KEY to erase it. Given the key, you can enter plaintext into the INPUT TEXT box and click ENCRYPT to see the ciphertext. Or just click SECRET to let the computer choose a random plaintext message and key.

    You can use the two tabs to help you discover the key, clicking DECRYPT after each change to see how well the current key is working. Or you can give up and click SHOW KEY to see the entire key.

    Letter Frequency

    Click on the LETTER FREQUENCY tab to see the frequency of standard english text (black) and the ciphertext (red). Notice that the tallest black bar is for "e", so "e" is the most common letter in typical plaintext. If you then see that the tallest red bar is for "u", you might guess that the ciphertext "u"corresponds to the plaintext "e". You can then continue guessing starting with the second most common character.

    Rather than manually looking for the Nth smallest black and red bar, you can look at the bottom graph, which is the same as the top graph, except the bars are sorted by height. The leftmost black bar is "e", so if the leftmost red bar is "u", you might guess that "e" encrypts to "u". To put this guess (and the other 25 analagous guesses) into the key, click SET KEY. You can then click on DECRYPT to see how well this guess worked. If the plaintext and ciphertext are too long to fit on the screen at the same time, you can click on "<" and ">" to move the text left or right, or ">>" to start back over at the beginning.

    Digrams

    You will probably find that just using the letter frequencies did not give a perfect decryption. It probably guessed the most frequent letters correctly (or almost correctly), but may have made more errors on the less frequent letters. A different clue can be found using pairs of letters. Click on the DIGRAM tab to see how common various pairs of letters are. For example, the most pair in english is "th". So if the most common ciphertext pair is "km", then it's possible "t" encrypts to "k" and "h" encrypts to "m". You can click on the graphs to create white crosshairs to help in reading the exact location of the red squares. Given all these clues, it should be possible to gradually work out all the characters of the key.

    Rate this content

    0
    Your rating: None

    Learn More


    Substitution Cipher from Wikipedia