# Most efficient way to crack a monoalphabetic substitution cipher with spacing intact

I've got a cipher I've been challenged to crack by hand. It's a monoalphabetic substitution cipher, and the English spacing is intact, so all of the words are the right size.

Is there a more efficient way to crack this cipher than frequency analysis?

## 2 Answers

Since you know where the word boundaries are, you can use word frequency analysis (either alone or combined with normal letter frequency analysis).

For example, in English text, the most common three-letter word is normally "the". Identifying it gives you the encryptions of three very common letters, and also some useful hints about the grammatical structure of the plaintext. Meanwhile, a single-letter word occurring several times in the middle of normal text (i.e. not close to other single letters, not always after the same preceding word) is very likely either "a" or "I", either of which gives you one more common letter.

Also, once you've identified "the", you can look for other short words that begin with the same letters. A four-letter word beginning with "the" is probably "they", "them" or possibly "then". If it begins with "th" but the next letter isn't "e", it's most likely "that" or "than" (and you'll know which, because you know what "t" encrypts to). Once you know what ciphertext letter stands for "a", you can start looking for three-letter words that begin with it, such as "and", "any", "all" and "are". Knowing a few other ciphertext/plaintext letter pairs will let you tell those apart. ("All" is easy to recognize anyway, because the last two letters are the same.)

Finally, once you've managed to determine the encryptions of a few common plaintext letters, you can start pattern matching longer words containing those letters with a dictionary. For example, "enQRSTtiUn" (where uppercase letter stand for yet unknown ciphertext letters) is almost certainly "encryption", while "XYtheXYtZQW" (note the repeating ciphertext letters!) most likely stands for "mathematics".

To make this easier, you may want to write a simple program (in whatever programming language you prefer) that reads a list of possible plaintext words (e.g. from any commonly available English word list) and one or more partially decrypted ciphertext words like above, and prints out all possible matches between them.

One approach I've experimented with is to solve it based purely on word patterns. Starting with the longest words, find all of the valid English words that match the pattern. Try each one in turn, tracking what it implies for your substitution mapping. At some point you may encounter an impossibility and you'll need to backtrack. This is a lot of work if you are doing it by hand, but it's not hard to automate. There are some obvious drawbacks: the plaintext words all have to be in your lexicon, so if there are any proper nouns or misspellings the approach won't find a solution. But it is pretty fast and doesn't rely on statistics so it can work on short or unrepresentative plaintexts.