# Can two cipher letters per plaintext letter easily defeat character frequency analysis?

For a class 5 years ago I wrote a paper about "defeating character frequency analysis by using two cipher letters per plaintext letter" (jamesjava.blogspot.com/2009/08/defeating-character-frequency-analysis.html).

Quote:

Using two letters in the cipher text for each letter in the plaintext can be a good way to create a flat character distribution.

The algorithm is to partition the 676 2-letter combinations based on the standard character frequency. i.e. if the standard frequency for a letter is 5% then it will get 5% of the 2-letter combinations (randomly selected). This doubles the size of the data, could include spaces & punctuation, and makes a much larger key.

Note that some letters may get dropped because they occur less than 1/676 (0.15%) of the time. Both 1-gram and 2-gram frequency analysis produce a nearly uniform histogram (variation appears to only be caused by rounding). Two-gram results: P&P=5,117%; SH=5,013%.

Therefore this technique was extremely effective with no obvious weaknesses.

I didn't get much feedback from the professor so I wonder if anyone can comment on this and tell me if my conclusion is correct.

-
Sounds like a homophonic substitution cipher. –  CodesInChaos Jun 18 '13 at 21:36
An extensive analysis of homophonic substitution ciphers can be found in this paper: Efficient Cryptanalysis of Homophonic Substitution Ciphers –  Reid Jun 19 '13 at 14:57
Could you copy the relevant paragraph from your paper into your question? This makes it easier to reference it in an answer. –  Paŭlo Ebermann Jun 20 '13 at 18:33
Given sufficient ciphertext, you can still do frequency analysis. All you did was make the alphabet much larger. –  Antimony Jul 3 '13 at 6:36
@JamesA.N.Stauffer Given a large enough ciphertext, bigrams and trigrams may still be analyzed. English text consists of roughly 1.5% "th" bigrams, for instance. Based on character frequency, there would be about 2,680 pairs representing "th". You'd need a plaintext large enough to reliably detect quartets occurring 0.00055% of the time, which isn't really all that large. –  Stephen Touset Jul 17 '13 at 22:47

It is probably impossible to remove language characteristics completely with a substitution cipher. Your algorithm flattens out single character frequencies, but that's it kinda.

Language bigrams (your cipher-quadruples) might not be uniform distributed. The reason for this is simple: Bigram probability is not just the product of the probabilities of both letters - they are not independent variables.

Let's make an example (frequencies from http://www.cryptograms.org/letter-frequencies.php):

• Letter t with frequency 0.09056 => 61 cipher-bigrams for t
• Letter h with frequency 0.06094 => 41 cipher bigrams for h
• Bigram th with frequency 0.03882
• Now there are $61*41=2501$ cipher quadruples for the original bigram th, and all of them have the same probability. However, $2501$ of $26^4 = 456976$ possible qudruples is just a fraction of 0.005473. So now the number of ciphertext quadruples for *th does not match required number to enforce a uniform distribution.

An other way to attack might work with those bigrams which are very unlikely or even impossible in English language.

-