# cryptanalysis, affine cipher

An affine cipher applies the affine tranform x -> ax + b mod 26
to the letters of the plaintext.
a must be prime to 26 for this map to be one-to-one and hence
the cipher to be decodable
(which it needs to be, for otherwise Bob is going to have a serious problem!).
To crytanalyse an affine cipher,
one tries to identify the preimages of two distinct letters in the
ciphertext, using frequency analysis.
Not every such assignment turns out to work, for instance
due to the condition to a.
Sometimes, one such assignment leads to two possible keys,
which are then tried out both. This is because arithmetic mod 26 isn't
over a field, and hence congruences may have several solutions.

You may try cryptanalyzing the following texts,
which were obtained from an english text by an affine cipher.
The messages need not be long for cryptanalysis to succeed.
This tells us something about the security of affine ciphers: it is low.

## task 1

Einstein about mathematics:

tpctitpwqvstrpncztwqvztwxhpivcviwnivtsxwfwqvftivgnwhviwtxgtgotpctitpwqvftivhviwtxgwqvfongnwivcviwnivtsxwf

## task 2

John von Neumann about mathematics:

pwfjuyzfjuprdbnlinwulwizmdujwiuypwhdbnlglduhzuldziunuyzf

## task 3

Dijkstra about an old fashioned programming language :

qgxtnxbarbobsrkjeesxnqgxvjyujqnqxlrgjydngbtsuqgxkxabkxoxkxdlkuxulnlrkjvjylsbaaxynx

## task 4

Adlai Stevenson on the US:

zgtpjwzbttglkxslbtgkjowjnzsjgeeitenxgjxaeijwznhnlxvethj

## task 5

:

## task 6

:

probabilities of letters in English text:
a .082
b .015
c .028
d .043
e .127
f .022
g .020
h .061
i .070
j .002
k .008
l .040
m .024
n .067
o .075
p .019
q .011
r .060
s .063
t .091
u .028
v .010
w .023
x .001
y .020
z .001
sorted:
e .127 vowel
t .091
a .082 vowel
o .075 vowel
i .070 vowel
n .067
s .063
h .061
r .060
d .043
l .040
c .028
u .028 vowel
m .024
w .023
f .022
g .020
y .020
p .019
b .015
q .011
v .010
k .008
j .002
x .001
z .001

created by A. Betten, August 23, 2003, last change August 23, 2003