Pages

Chapter 3

Cracking the Code 

When using ciphers, it is always important to understand how an adversary might decipher, or “crack”, your code. Knowing the techniques of code breaking can help you to devise systems that combat this effort. For example, notice that in the following encrypted message there are two single-letter words represented by the letter g.
It turns out that there are only three single-letter words in the English language; a, I, or O. It would be reasonable to guess that the letter “a” might be associated with “g” in this secret message.
Assuming a rotation cipher, fill in the rest of the alphabet to obtain a rot6 key.
Use this key to decode the message to see that the meaning is clear. 

------------------------------------
plaintext:  a night attack is a must
ciphertext: g tomnz gzzgiq oy g sayz
------------------------------------


With a simple well thought out guess, we cracked the code very quickly. To combat the fact that word length can help code breakers, spacing is often eliminated.

gtomnzgzzgiqoygsayz

Eliminating space and punctuation disguises the word boundaries. Though it turns out that sending long strings of seemingly random letters is a bit cumbersome. To help avoid transmission errors, the letters are often grouped in manageable sets of 5.

gtomn zgzzg iqoyg sayz

Another way to crack a rot-n cipher is to simply try all possible keys until the decoded message makes sense. Trying all possible keys is called a “brute force” crack and can be very time consuming. However, this method can certainly be programmed into a computer where it can be carried out very quickly.
Pictured is a machine called the “bombe” which was used to help decipher coded messages made using the infamous Enigma cipher. During WWII, the British bombe was initially designed by Alan Turing, whose ideas helped develop the modern digital computer. 

--------------------------------
Mission 5: Crack the rot-n cipher:

plaintext:
ciphertext: l zloo zdlw iru d vljqdo

plain:
cipher: abcdefghijklmnopqrstuvwxyz

--------------------------------
Mission 6: Group the secret message to hide the word sizing.

ciphertext: l zloo zdlw iru d vljqdo

grouped ciphertext:

---------------------------------


The number of times a letter occurs in a message is called its frequency. Each letter in a message has an average relative frequency. For example, in the English language, the letter e occurs an average of about 12 times for every 100 letters in a message.
From the chart, you can see that e is the most frequent letter followed by t and then a. This knowledge can be used to guess the letters in any substitution cipher, even if it is grouped to hide word boundaries.
You can see in the encoded message above that m is the most frequent letter with five occurrences (count them). It would be reasonable to guess that m could be associated with e in a rotation cipher.
Filling in the plaintext alphabet we obtain a rot8 key.
Using this key, the message becomes clear. 
------------------------------
amvlb pmmvo qvmmz anwze izl
sendt heeng ineer sforw ard

send the engineers forward
------------------------------

Using letter and even word frequencies is a common way to crack ciphers and secret codes. Here are some helpful frequency facts listed in order of most frequent:

Initial letters: t o a w b c d s f m
Final letters: e s t d n r y f l o
Common doubles: ss ee tt ff ll mm oo


When studying cryptography, you will find that there are many useful frequency facts about letters, combinations of letters, and even words. This kind of code breaking is called frequency analysis and works best on longer messages.
The first known recorded explanation of frequency analysis is attributed to Al-Kindi in the 800’s (that is the 9th century). 

------------------------
Mission 7: Crack the grouped rot-n ciphertext using letter frequencies.

plaintext:
ciphertext: uhfrx qwwkh ohwwh uv

plain:
cipher: abcdefghijklmnopqrstuvwxyz

------------------------
Mission 8: Crack the grouped rot-n ciphertext using letter frequencies.

plaintext:
ciphertext: ywjfx zwjns ymjqn yyqjy wzsp

plain:
cipher: abcdefghijklmnopqrstuvwxyz

------------------------