# Cryptography and Cryptanalysis

```Cryptography and Cryptanalysis
The word &quot;cryptography&quot; comes from the Greek roots meaning &quot;hidden writing&quot;.
Cryptography is the art of creating codes and ciphers, ways of making a message
understandable to only a select group of people, while cryptanalysis is the art of figuring
out how to read this &quot;hidden writing&quot;. Codes are basically secret languages, and you
simply only give dictionaries to the people that you want to be able to read them. They
tend to be very difficult to figure out without gaining access to the secret dictionary.
Today, our attention will be focused on ciphers, which are ways of scrambling messages
instead of translating them. The simplest ciphers involve shifting the letters of the
alphabet by some number. For example, below to the left, I replace every letter with the
letter 3 letters after it in the alphabet, a --&gt; D, b--&gt; E... looping back to ABC after Z.
a ---&gt; D
Julius Caesar was one of the first people to use ciphers such as this for
b ---&gt; E
military communications. With the English alphabet, there are only a few
c ---&gt; F
ways to do this, so it is a very easy cipher to crack: just check each one.
d ---&gt; G
These are examples of substitution ciphers, ways of simply replacing
e ---&gt; H
letters with different ones. Clearly, there are many substitution ciphers,
f ---&gt; I
so you can no longer hope to simply check them all (the so-called &quot;brute
g ---&gt; J
force&quot; method). However, there are still ways to crack such ciphers with
h ---&gt; K
relative ease using a method first devised by the medieval Arab scholar
i ---&gt; L
al-Kindi, now called frequency analysis. The idea is very simple: use what
j ---&gt; M
you know about the language being encrypted to crack the cipher! For
k ---&gt; N
example, in English, the letters &quot;e&quot;, &quot;t&quot;, and &quot;a&quot; occur most often while
l ---&gt; O
&quot;j&quot;, &quot;q&quot;, &quot;x&quot;, and &quot;z&quot; occur least often. We also know something about
m ---&gt; P
how some pairs of letters, or digraphs, are distributed. For example, &quot;ee&quot; is
n ---&gt; Q
common, but how many words have &quot;aa&quot; or &quot;ii&quot;? Just think of common
o ---&gt; R
digraphs and use this to help you break the cipher. Also, sometimes the
p ---&gt; S
message will have a certain form to it, such as a letter starting with &quot;Dear&quot;.
q ---&gt; T
Sometimes, a message will use the word &quot;stop&quot; at the end of a sentence.
r ---&gt; U
Other kinds of ciphers involve physically scrambling the message. For
s ---&gt; V
example, the ancient Spartans used to wrap a strip of parchment around
t ---&gt; W
a stick and then write the message vertically down the stick. When they
u ---&gt; X
unwrapped it, the message would look like nonsense to anyone who didn't
v ---&gt; Y
know to wrap it around a stick of the same diameter. You can usually tell
w ---&gt; Z
that a transposition cipher has been used if frequency analysis gives the
x ---&gt; A
same distribution of letters as in a normal sample of the language (&quot;e&quot;
y ---&gt; B
very common, etc.). You might have fun coming up with your own cipher
z ---&gt; C
to use in sending messages to your friends.
```