Hacking Secret Ciphers with Python

(Ann) #1
Chapter 20 – Frequency Analysis 303

Figure 20-3. How the frequency match score of ASRXJILPWMCYOUEQNTHBFZGKVD is calculated.


The above ciphertext was encrypted with a simple substitution cipher, which is why the
frequency match score isn’t very high. The letter frequencies of simple substitution ciphertext
won’t match regular English’s letter frequencies.


Another Example of Calculating Frequency Match Score
For another example, look at this ciphertext which was encrypted with a transposition cipher:


“I rc ascwuiluhnviwuetnh,osgaa ice tipeeeee slnatsfietgi tittynecenisl. e fo f
fnc isltn sn o a yrs sd onisli ,l erglei trhfmwfrogotn,l stcofiit.aea
wesn,lnc ee w,l eIh eeehoer ros iol er snh nl oahsts ilasvih tvfeh rtira id
thatnie.im ei-dlmf i thszonsisehroe, aiehcdsanahiec gv gyedsB affcahiecesd d
lee onsdihsoc nin cethiTitx eRneahgin r e teom fbiotd n
ntacscwevhtdhnhpiwru”


The ordering of most to least frequent letters in the above ciphertext is:
EISNTHAOCLRFDGWVMUYBPZXQJK. (That is, E is the most frequent letter, I the 2nd most
frequent letter, and so on.)


Of the top and bottom six letters in this ordering, the four letters E, I, N, and T appear in ETAOIN
and the five letters Z, X, Q, J, and K appear in VKJXQZ. This gives the ordering a frequency
match score of 9.


Figure 20-4. How the frequency match score of EISNTHAOCLRFDGWVMUYBPZXQJK is calculated.

Free download pdf