        ĳ
                                +-+-+-+-+-+-+-+-+
         ۲|O|u|t|b|r|e|a|k|𰰰
                                +-+-+-+-+-+-+-+-+
                             Issue #5 - Page 7 of 13 
        ĳ

Cryptoanalysis of an affine cipher
----------------------------------
by: Encrypted

The objective of cryptoanalysis is to "crack the code", ex. - to recover the 
plaintext from the ciphertext, and also to find which key was used. I will 
discuss some methods of cryptoanalysis. Understanding the methods of cryptoanalysis
is important not only for the cipher breaker "alpha", but also for the cipher users 
"bravo" and "charlie", since they want to make sure that their communication is
reasonably secure.

The Kerckhoff's Principle. The Kerckhoff's Principle is the general assumption 
that the opponent, Alpha", knows which cryptosystem is being used. 

There are different levels of attacks on a cryptosystem.

Ciphertext-only attack. We are assuming the opponent possesses a string of 
ciphertexts

Known plaintext. The opponent possesses a string of plaintexts, and the 
corresponding string of ciphertexts. 

Chosen plaintext. The opponent has a temporary access to the encryption machinery, 
so that he can choose a plaintext string and construct the corresponding ciphertext
string. 

The weakest type of attacts is the ciphertext-only attack. If the keyspace of
the cryptosystem is small, then the method of exhaustive search can be applied.
In the case of a large keyspace, there exist other methods which are based on 
the statistical properties of languages.

Statistical properties of the English.

We assume that plaintext and cyphertext characters are characters of the English 
alphabet, and that the plaintext is an ordinary English text.

Frequency of appearance of a character. The English characters do not appear 
in ordinary texts with the same frequency. People have estimated relative 
frequencies of the 26 English characters by compiling statistics from books, 
magazines. Below is a table I found somewhere on the net. I didnt make it im 
not that smart.  
 
   A    B    C    D    E    F    G    H    I    J    K    L    M 
 .082 .015 .028 .043 .127 .022 .020 .061 .070 .002 .008 .040 .024 

   N    O    P    Q    R    S    T    U    V    W    X    Y    Z
 .067 .075 .019 .001 .060 .063 .091 .028 .010 .023 .001 .020 .001 

Probability of occurence (i hope that iz worded right. heh)

1. E ( probability .127). 
2. T,A, O, I, N, S, H, R ( probability between 0.06 and 0.09). 
3. D, L (probability around 0.04). 
4. C,U, M, W, F, G, Y, P, B (probability between 0.015 and 0.023). 
5. V,K,J,X,Q,Z ( probability less than 0.01). 

There are also combinations of two and three letters, called digrams and trigrams,
that are frenquently met. In decreasing order, the most common digrams and trigrams
are:

TH  HE  IN  ER  AN  RE  ED  ON  ES  ST  EN  AT  TO  NT  HA 
ND  OU  EA  NG  AS  OR  TI  IS  ET  IT  AR  TE  SE  HI  OF

THE  ING  AND  HER  ERE  ENT 
THA  NTH  WAS  ETH  FOR  DTH

These statistical properties can be used effectively for attacks on ciphers having 
a relatively large keyspace.


                               Cryptoanalysis  of the Affine Cipher 
 
 
An example of cryptanalysis of an affine cipher. Suppose the ciphertext obtained 
from an affine cipher is: 
    
                     fmxvedkaphferbndkrxrsrefmorudsdkdvshvufedkaprkdlyevlrhhrh

count the number of occurrences of the 26 ciphertext letters

a  b  c  d  e  f  g  h  i  j  k  l  m  
2  1  0  6  5  4  0  5  0  0  5  2  2 

n  o  p  q  r  s  t  u  v  w  x  y  z 
1  1  3  0  8  3  0  2  4  0  2  1  0 

reaarange the ciphertext characters in the following table of decreasing number 
of occurences 

r  8 occurrences 
d  6 occurences  
e,h,k  5 occurrences 
f,s,v  4 occurrence 

Comparing with the table of frenquencies of English alphabet characters, our first 
guess is that r is an encryption of E and d is an encryption of T. 

Ok. Here are some formulas to decipher the code, but they are kinda hard to udnerstand 
and you need to understand Algebra really well. It kinda hard to display them in the 
correct diagram also since im using notepad but ill give it a try. These were gathered 
from various websites and programs so these arent my equations. Im not that smart. 
Fuck it took me months to understnad the dam equations myself.
                


              All information below this line iz copied and not my original work
                                 (didnt want to be a thief)
_____________________________________________________________________________

Comparing with the table of frenquencies of English alphabet characters, our first guess 
is that r is an encryption of E and d is an encryption of T. If this were true, we would 
have EK(E) = r, EK(T) = d, or EK(4) = 17, EK(19) = 3. Recall that for affine ciphers 

                                      EK(x) = ax+b mod 26

so we have 

                           4a+b = 17 
                          19a +b = 3 
(heh, if you understand any of this shit email me and ill send u txts on deciphering more 
advanced keys. heh.)

Our next guess is EK(E) = r, EK(T) = e. This gives EK(4) = 17, EK(19) = 4, 
and the corresponding system 

so we have

                           4a+b = 17
                          19a +b = 4
(heh, your gettin into more than u can handle aint u)


The next possibility is EK(E) = r, EK(T) = h. This gives EK(4) = 17, EK(19) = 7, and the system 

so we have


                           4a+b = 17
                          19a +b = 7
(lol, your still reading? i hope u understand algebra. heh)


The next guess is EK(E) = r, EK(T) = k, or EK(4) = 17, EK(19) = 10, and the system 

so we have

                           4a+b = 17
                          19a +b = 10

Solving this system gives a = 3, b = 5. Since gcd(3,26) = 1, this is an eligible pair. 
So we test for the key K = (3,5), use the decryption function associated with this key 
to decrypt the message to see if it has any sense

_________________________________________________________________________________________________

Well thats it for cracking an affine cipher. Next months issue will be on Cryptoanalysis  
of the Substitution Cipher. If you want all the cryptoanalysis txt's then plz email me. If you dont 
understand algebra then plz dont try to learn cryptoanalysis, all your gonna do iz fail. 

-[encrypted] prokzide@charter.net
