Encryption for the Caesar with key

Encryption for the Caesar with key

The encryption of the Caesar key was created to increase the security of the encryption of Caesar, that is to say, the distance of oneness, we include in the alphabet of the encryption key k that consists of a word or phrase that is written from a position p_0 of the alphabet in clear

The repeated characters of the key are not used. Once you positioned the key at the given position, add the other letters of the alphabet in order and in a modular way, in order to get the alphabet encryption

In this type of encryption fails to meet the condition of constant displacement

Example of encryption is the Caesar with key

We take p_0 = 3 and the key is going to be:

k = I’M BORED

To encrypt we will use:

C_i\equiv(M_i+b)\pmod{n}

To decrypt we will use:

M_i\equiv(C_i+n-b)\pmod{n}

In the English alphabet, as there are 26 letters, n will be 26

We have the following message that we want to encrypt:

C=MESSAGE SENT YESTERDAY

Their characters clearly correspond to the following matrix:

\tiny\begin{pmatrix}0& 1& 2& 3& 4& 5& 6& 7& 8& 9& 10& 11& 12& 13& 14& 15& 16& 17& 18& 19& 20& 21& 22& 23& 24& 25 \\ A& B& C& D& E& F& G& H& I& J& K& L& M& N& O& P& Q& R& S& T& U& V& W& X& Y& Z \\ \end{pmatrix}

To the previous matrix we add the key, taking into account the need to eliminate the repeated

\tiny\begin{pmatrix} 0& 1& 2& 3& 4& 5& 6& 7& 8& 9& 10& 11& 12& 13& 14& 15& 16& 17& 18& 19& 20& 21& 22& 23& 24& 25 \\ A& B& C& D& E& F& G& H& I& J& K& L& M& N& O& P& Q& R& S& T& U& V& W& X& Y& Z \\ & & & I& M& B& O& R& E& D \\ \end{pmatrix}

Now we add the other letters of the alphabet in order and in a modular way, in order to get the alphabet full encryption

\tiny\begin{pmatrix} 0& 1& 2& 3& 4& 5& 6& 7& 8& 9& 10& 11& 12& 13& 14& 15& 16& 17& 18& 19& 20& 21& 22& 23& 24& 25 \\ A& B& C& D& E& F& G& H& I& J& K& L& M& N& O& P& Q& R& S& T& U& V& W& X& Y& Z \\ X& Y& Z& I& M& B& O& R& E& D& A& C& F& G& H& J& K& L& N& P& Q& S& T& U& V& W \\\end{pmatrix}

We get the following results:

\begin{array}{l} (12+3)\pmod{26}\equiv 15 \\ (4+3)\pmod{26}\equiv 7 \\ (18+3)\pmod{26}\equiv 21 \\ (18+3)\pmod{26}\equiv 21 \\ (0+3)\pmod{26}\equiv 3 \\ (6+3)\pmod{26}\equiv 9 \\ (4+3)\pmod{26}\equiv 7\\ (18+3)\pmod{26}\equiv 21 \\ (4+3)\pmod{26}\equiv 7 \\ (13+3)\pmod{26}\equiv 16 \\ (19+3)\pmod{26}\equiv 22 \\ (24+3)\pmod{26}\equiv 1 \\ (4+3)\pmod{26}\equiv 7 \\ (18+3)\pmod{26}\equiv 21 \\ (19+3)\pmod{26}\equiv 22 \\ (4+3)\pmod{26}\equiv 7 \\ (17+3)\pmod{26}\equiv 20 \\ (3+3)\pmod{26}\equiv 6 \\ (0+3)\pmod{26}\equiv 3 \\ (24+3)\pmod{26}\equiv 1 \end{array}

by applying the transformation P+3\pmod{26} and by referring to the second part of the matrix become

\tiny\begin{pmatrix} 15& 7& 21& 21& 3& 9& 7& 21& 7& 16& 22& 1& 7& 21& 22& 7& 20& 6& 3& 1 \\ J& R& S& S& I& D& R& S& R& K& T& Y& R& S& T& R& Q& O& I& Y \\ \end{pmatrix}

So we is that the encrypted message is:

M=JRSSIDRSRKTYRSTRQOIY

We can decipher the M previous:

\begin{array}{l} (15+26-3)\pmod{26}\equiv 12 \\ (7+26-3)\pmod{26}\equiv 4 \\ (21+26-3)\pmod{26}\equiv 18 \\ (21+26-3)\pmod{26}\equiv 18 \\ (3+26-3)\pmod{26}\equiv 0 \\ (9+26-3)\pmod{26}\equiv 6 \\ (7+26-3)\pmod{26}\equiv 4 \\ (21+26-3)\pmod{26}\equiv 18 \\ (7+26-3)\pmod{26}\equiv 4 \\ (16+26-3)\pmod{26}\equiv 13 \\ (22+26-3)\pmod{26}\equiv 19 \\ (1+26-3)\pmod{26}\equiv 24 \\ (7+26-3)\pmod{26}\equiv 4 \\ (21+26-3)\pmod{26}\equiv 18 \\ (22+26-3)\pmod{26}\equiv 19 \\ (7+26-3)\pmod{26}\equiv 4 \\ (20+26-3)\pmod{26}\equiv 17 \\ (6+26-3)\pmod{26}\equiv 3 \\ (3+26-3)\pmod{26}\equiv 0 \\ (1+26-3)\pmod{26}\equiv 24 \end{array}

We consulted the first part of the array

\tiny\begin{pmatrix} 12& 4& 18& 18& 0& 6& 4& 18& 4& 13& 19& 24& 4& 18& 19& 4& 17& 3& 0& 24 \\ M& E& S& S& A& G& E& S& E& N& T& Y& E& S& T& E& R& D& A& Y \\ \end{pmatrix}

Getting the original C:

C=MESSAGESENTYESTERDAY

By having a greater number of combinations of alphabets, there is a greater uncertainty with respect to the key. The distance of the uniqueness of this cipher will be higher and, therefore, the system will present greater strength

Cryptanalysis of the encryption of Caesar with key

It is impossible to establish a mathematical relationship only and directly between the alphabet in clear and the alphabet cipher. The only way that remains for us is to take statistics on the language of the cryptogram, by observing for example the relative frequency of appearance of the characters in the cipher text

This type of statistical attack will be valid for the encrypted type monoalfabético with key as well as for those who have not. Now, in the great majority of cases it will be necessary to have a number of a cipher, quite higher than that of the previous example, a dash of intuition and a bit of luck

The distance of the uniqueness is given by the ratio between the entropy of the key H(K) and the redundancy of the language D. therefore, if the alphabet has n characters, there will be n! combinations of elements of n, therefore N=\frac{H(K)}{D}=\frac{\log_2{n!}}{D}

If we use the approximation of Sterling we have that \log_2{n!}\approx n\cdot\log_2{\frac{n}{e}} therefore, the distance of oneness will be N=\frac{n\cdot\log_2{\frac{n}{e}}}{D}. As the redundancy D was equal to 4.03 and n = 26 has to be N=\frac{26\cdot\log_2{\frac{26}{e}}}{4,03}\approx 21,02. Therefore, we need at least 22 characters

When set to the encryption operation is a direct correspondence between the characters of the clear text and alphabet encrypting, maintaining the same frequency relationship related feature of the language. Therefore, it is very likely that the letter C_i the cipher text with a higher relative frequency corresponds with the letter M_i greater relative frequency in the language.

Therefore, if the letter W is the largest frequency in the cryptogram, we can assume with very good expectations of success, that is the letter And the text clear and that, therefore, the offset applied has been equal to 18, the distance which separates the two letters in the alphabet

These assumptions will only have some validity if the amount of cipher text is large, and therefore met the statistical properties of the language. In the background you are making a comparison of the frequency distribution of all the elements of the cryptogram with the feature of the language, with the object of finding that constant displacement