Category Archives: Cryptography

Cryptography deals with the techniques of encryption and subsequent decryption, intended to alter the representations of language of certain messages to make them unintelligible to unauthorized recipients

Cryptography

Cryptography

The history of cryptography is long. Since the first civilizations developed techniques to send messages during military campaigns, so that if the messenger was intercepted the information that he had not run the danger of falling into the hands of the enemy

Since the times of Ancient Egypt up to today has been a long time, but there is something that has not changed: the desire of the human being by hiding their secrets

Ancient

Characters such as Cleopatra or Caesar already learned to appreciate the importance to hide from prying eyes your messages. The Scilata that the spartans used back in the year 400 B. C. or the own code Caesar (a simple scroll alphabetically) were the beginnings

With the development of the sciences, and, more specifically, of mathematics, cryptography grew up as a younger brother, hand in hand. In the Middle Ages began to acquire a great importance when a servant of Pope Clement VII wrote the first manual on the topic of the story in the old continent

In 1466 Leon Battista Alberti devised the system polyalphabetic based on the rotation of a roller. A century later, Giovanni Battista Belaso invents the cryptographic key based on a word or text that you are transcribing letter by letter on the original message

The Twentieth century

Already at the beginning of the last Twentieth century devised the denominated “translators mechanics”, based on the concept devised in the XV century by Alberti of the wheels concentric, and the system began to become extremely complex, since it is not enough to analyze it thoroughly to understand it. And that led to the Second World War, to the years 30 and 40 and to the Enigma machine

Although a lot of people don't know, the cryptography was one of the main reasons for the allies to win the war, because the germans believed the code of their Enigma machine as inviolable, and in fact yes that was extremely complex. But like before I said that the human desire to hide secrets is eternal, so is his longing for unearthing other people's secrets

A team of criptoanalistas, mathematicians, and other minds, the privileged (among them Alan Mathison Turing, one of the fathers of computer science) won in 1942 what seemed impossible: to break the encryption of Enigma

To do so, they designed the so-called “bombs naval” (la bombe de Turing), equipment of calculation mechanics who were in charge of breaking the German encryption and deliver all the secrets to the allies

Also, the Purple (japanese version of Enigma) was broken Midway by a team led by commander Joseph J. Rochefort. The fact that you know the secrets, you have all the keys (never better said), turned the war and changed the course of history. And the world will never again be the same

Cryptography today

The birth of computers and the cryptosystems computer was a radical change of the concept of cryptography, and cryptanalysis. The cryptosystems and algorithms increased suddenly and unwieldy complexity

From the DES a long time ago, until the cryptosystems asymmetric elliptic curves today everything has changed too much, but one of those changes has been the second major turning point of cryptography: PGP

Until then, the privilege of keeping secrets was exclusively in the hands of the governments or the powerful, and today, probably thanks to PGP, is a right of any citizen by humble (although in some countries is not so). Risking much, Arthur Zimmermann we opened the doors to the cryptography, and the freedom to communicate safely

Of course there are other names that are capital in the development of cryptosystems computer, apart from Zimmermann: Rivest, Shamir, Adleman, Diffie, Hellman, ElGamal, Rijmen, Daemen, Massey, Miller, Goldwaser... they are All fathers of what today is called cryptography

Basic concepts

Cryptology

Cryptography art of hide. The word has its origin in the Greek: kryptos (hidden, hidden) and graphein (to write). The art of concealing a message by means of conventional signs is very old, almost as much as the writing

And effectively has always been considered an art until relatively recently, when Claude Elwood Shannon published in two years, two documents that constituted the foundation of modern Information Theory. These documents are:

  • A mathematical theory of communication
  • Communication theory of secrecy systems

Cryptography the art of writing with a secret key or in an enigmatic manner

Cryptanalysis art of deciphering cryptograms

Clear text and cryptograms

In the area of cryptographic, we understand by clear text any information that is readable and understandable per se. A clear text would be any information before being encrypted or after being decrypted. It is considered that any information is vulnerable if you are in this state

Likewise, we call cryptogram any information that is suitably encrypted and will not be readable or understandable for the rightful recipient of the same

The mechanism of transforming a plain text into a cipher, what we call encryption or encryptionand the process of retrieval of information from a cryptogram we call decryption or decryption

It is very important not to confuse these terms with encoding or decoding

Encoding is the act of representing information in different ways, but not necessarily encrypted. For example, a decimal number may be encoded as hexadecimal, and turns into a cryptogram

Flow of information

In a cryptosystem, the information continues to flow is always fixed:

Information flow

The sender encrypts the plain text to obtain the cryptogram, which travels through a channel noisy. The receiver decrypts the cipher, and again obtains the plain text that the sender sent him. During the transmission, the message is unreadable

Cryptosystems

First of all, it is convenient to define what we mean “mathematically” by cryptosystem. A cryptosystem is a quarternary of elements formed by:

  • A finite set called the alphabet, which according to rules of syntax and semantics, allows to emit a message in clear as well as its corresponding cryptogram
  • A finite set called the key space formed by all the possible keys both for encryption as for decryption, the cryptosystem
  • A family of applications in the alphabet in itself, which we call transformations of encryption
  • A family of applications in the alphabet in itself, which we call transformations of decryption

We already know what is a cryptosystem, but what is a cryptosystem computer? A cryptosystem computer would be defined by the following four elements:

  • A finite set called the alphabet, which allows to represent both the clear text as the verification value. At low level we would speak of bitsand at a higher level we could speak of the characters ASCII or MIME
  • A finite set called the key space. Would be constituted by all the possible keys of the cryptosystem
  • A family of transformations, arithmetic-logic, which we call transformations of encryption
  • A family of transformations, arithmetic-logic, which we call transformations of decryption

It is simply a cryptosystem adapted to the possibilities and limitations of a machine. The alphabet or space characters is usually a standard representation of information (typically MIME or UNICODE for compatibility reasons) and the lowest level, by bit. The transformations of both encryption and decryption follow the rules of programming computers today

In reality, for all practical purposes there is not much difference between cryptosystem mathematical and computer, since mathematicians tend to design thinking in their programming in a machine (because only computers have the power necessary to support the complex algorithms) and the software is developed always with a mathematical basis

Cryptographic algorithm

A algorithm you must describe uniquely and without giving rise to interpretations, the solution to a problem in a finite number of steps concrete

Encryption algorithm, is a description clear and specific of how a cryptosystem given

Cryptographic key

The concept of a cryptographic key that arises with the concept of cryptography, and is the soul of an encryption algorithm

Obviously, an algorithm must possess the ability to be worn many times without that its mechanism is identical, because, otherwise, each person should have their own encryption algorithm

To implement this functionality, use the keys. The key it is a data it intervenes actively in the implementation of the algorithm and customizes it

Solely to the type of key, we can distinguish between two cryptosystems:

  • Systems or unique key cryptosystems, symmetric
    Are those in which the encryption and decryption processes are carried out by a single key
  • Of public key systems or cryptosystems asymmetric
    Are those in which the encryption and decryption processes are carried out by two different keys, and complementary

Key length

Today, thanks to computers it is possible to perform complex mathematical computations in a space of relatively short time. Thus, the field of cryptanalysis is closely linked to this computing power

For that an algorithm is considered secure, his cryptanalysis without the required key should be computationally impossible to solve

We consider it “impossible” to solve a system whose violations need greater resources (financial or time) that the benefit reported. For example, it is considered secure a cryptosystem that requires thousands of years for decryption

To achieve such a complexity, address numbers or sets of numbers huge. It is obvious that the greater the size of these numbers, there is a greater number of possible keys, and the possibility of success of the cryptanalysis is less

Today this size is called the key length, and is typically measured in the bit that holds the key. So, a key number of 1024-bit would be any number from 0 up to the 1,8\cdot 10^{308} (2^{1024})

By representing the key lengths as powers of two, it is important to realize the relationship between the lengths of key. A key 1025 bits is the double of long that a 1024 - (2^{1025} front 2^{1024})

Today use keys ranging from 512 bits and 4096 bits in length

Encryption by substitution

Encryption by substitution

A encryption by substitution is the one which replaces each character of plain text by another character in the cipher text or cryptogram

Is based on applying the principle of confusion proposed by Shannon, hiding the text in clear to the intruder through substitutions, except for the recipient, who know the algorithm and key to recover the message

The ciphers by substitution can be classified into three groups:

  • Monoalphabet monogamous substitution The encryption is done using an algorithm that maps a letter of the clear text to a single letter in the cryptogram, that is to say, a figure monograms

    Hence its monogamy encryption designation

    As regards the term monoalphabet means that it uses a single alphabet of encryption, the same as the text in clear or a mixed one, but distributed either randomly or through a mathematical transformation

    Then, if the letter M of the plain text corresponds to the letter V, or the symbol # to the alphabet of encryption, will be encrypted always the same, since there is a unique equivalence or, which is the same thing, a single alphabet encryption

  • Polyalphabet monogamous substitution the encryption operation is also performed character by character, that is to say by monograms

    As regards the term polialphabetmeans that it uses multiple alphabets for encryption, applied to the same character in the text in clear or a mixed one, but distributed either randomly or through a mathematical transformation

    However, through a key, algorithm or mechanism, you get multiple alphabets of encryption so that the same letter can be encrypted with different characters, depending on their position within the text in clear

  • Polygamic substitution treat the message in blocks of two or more characters on which it is applied the transformation of the cryptosystem in question, substituting n-grams of the message by n-gram of ciphertext

Encryption monoalphabetic

Encryption monoalphabetic

A cipher system is monoalphabetic when each character is replaced by a determined character in the alphabet of the cipher text

From the ancient times to our days, have sent secret messages

The need to communicate secretly has occurred in diplomacy and between military

With the advent of electronic communications, the interest in maintaining messages unintelligible to all except the receiver has done nothing but increase

To introduce a few terms before we get in, we will say that cryptology is the discipline dedicated to communicate secretly

Cryptography is part of cryptology that deals with the design and implementation of systems secrets and cryptanalysis which is dedicated to break such systems

I would like to start with a very simple system that can be explained mathematically speaking using modular arithmetic

Perhaps the first of these systems had their origin with Julius Caesar, encryption was simply to replace a letter by the one three places further in the alphabet that is To be transformed into D, B into E, and so on until Z became C

Throughout this article for simplicity I will use standard English alphabet 26 letters:

\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}

Which is enough for most of the encrypted text-based and has the advantage of occupying positions in successive ASCII code, which makes it very advantageous to schedule

Well, the cipher of Julius Caesar could be expressed as well C\equiv P+3\pmod{26} where we have assigned the number 0, B 1, ... , Z to 25, and \pmod{26} indicates that we should take the remainder of dividing by 26 (in C language we use the % operator ) C is the ciphertext and P the original

Frequency of letters

In the cryptanalysis of some classical methods it is interesting to know the frequency of letters, pairs of letters, and words in the language in which we assume that it is written that message

Here are some data useful for the English language:

Letters high-frequency
Letter Frequency %
E 12,70
T 9,06
A 8,17
O 7,51
I 6,97
N 6,75
S 6,33
H 6,09

Letters of average frequency
Letter Frequency %
D 4,25
L 4,03
C 2,78
U 2.76
M 2,41
W 2,36
F 2,23
G 2.02

Letters of low frequency
Letter Frequency %
Y 1,97
P 1,93
B 1,49
V 0,98
K 0,77

The rest of the letters J, Q, X and Z have frequency less than 0.5% and can be considered so “rare”

Summarizing the above data and applying them by groups of letters, we could say:

  • The vowels occupy about 38% of the text

  • Only the E and the A are identified with relative reliability because they stand out much over the others

  • The letters of high frequency and accounted for 63% of the total

  • The consonants most frequent are T, N, S, H (around 28%)

  • The letters least common are J, Q, X and Z (little more than 1%)

Most frequent words
Word Frequency (per billion)
THE 56271872
OF 33950064
AND 29944184
TO 25956096
IN 17420636
I 11764797
THAT 11073318
WAS 10078245
HIS 8799755
HE 8397205
IT 8058110

Two-letter words
Word Frequency (per billion)
OF 33950064
TO 25956096
IN 17420636
HE 8397205
IT 8058110
IS 7557477
AS 7037543
BE 5662527
ON 5113263
AT 5091841

Three-letter words
Word Frequency (per billion)
THE 56271872
AND 29944184
THAT 11073318
WAS 10078245
HIS 8799755
FOR 7097981
HAD 6139336
YOU 6048903
NOT 5741803
HER 5202501

Four-letter words
Word Frequency (per billion)
WITH 7725512
HAVE 4346500
FROM 4108111
WERE 3323884
SAID 2637136
THEM 2509917
BEEN 2357654
WILL 2320022
WHEN 1980046
MORE 1899787

Example of encryption monoalphabetic

MESSAGE SENT YESTERDAY we break the structure in the words of the message by deleting punctuation marks, if any, by putting for example MESSAGESENTYESTERDAY and, we get the numerical equivalents of these letters:

\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}

by applying the transformation P+3\pmod{26} become

\tiny\begin{pmatrix} 15& 7& 21& 21& 3& 9& 7& 21& 7& 16& 22& 1& 7& 21& 22& 7& 20& 6& 3& 1 \\ P& H& V& V& D& J& H& V& H& Q& W& B& H& V& W& H& U& G& D& B \\ \end{pmatrix}

that is to say the encrypted message is now PHVVDJHVHQWBHVWHUGDB

A cipher of this type is ridiculously easy to break (but remember that it was also very easy to do), it is sufficient to test 25 possible offsets from P + 1 to P + 25, and with a glance we will know which is the message

We have used in this case, a cryptanalysis called “brute-force” because we test all the keys (in this case displacement) possible

There are some ways to improve this method, without complicate it too much, the first is based on choosing a key word with all different letters, let's say that we choose VIRTUAL ZONE

We write then the normal alphabet along with the transformed as follows:

\tiny\begin{pmatrix} 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 \\ V& I& R& T& U& A& L& Z& O& N& E& B& C& D& F& G& H& J& K& M& P& Q& S& W& X& Y \\ \end{pmatrix}

and now the message along with the encryption would be

\tiny\begin{pmatrix} M& E& S& S& A& G& E& S& E& N& T& Y& E& S& T& E& R& D& A& Y \\ C& U& K& K& V& L& U& K& U& D& M& X& U& K& M& U& J& T& V& Y \\ \end{pmatrix}

now a brute-force attack is “somewhat” more expensive so you should try with all the alphabets of possible substitution that are 26!=403291461126605635584000000 or is a few more than the 25 from before

This method has the following weakness: with certain keys, the final letters of the alphabet are left unchanged, and this greatly facilitates the work of the cryptanalyst

The key in our example is chosen so that they appear in her letters as V, U, Z near the end of the alphabet, and they produce a greater “disorder” in the alphabet transformed

In any case, in an encryption like this uses what is called a frequency analysis. Consists of: knowing the frequency of letters in English (if you don't know in what language it is written in the original can cost you more work) try to guess which letter corresponds to each one of them

For example, in the last encrypted message CUKKVLUKUDMXUKMUJTVY it is noted that the letter repeated is the U, like the letter most frequent in English, is the And we may conjecture that U corresponds with the E as in effect and is following with the other letters can be ascertained enough to be able to read the original message

Encryption of Caesar

Encryption of Caesar

In the first century B. C. appears a basic cipher known as the generic cipher of Caesar in honor of Emperor Julius Caesar and in which a transformation is already applied to the monoalphabetic clear text

The cipher of Caesar applied a constant displacement of b characters to the text in clear

Example of encryption is the Caesar

We take b equal to 3, so that the alphabet of the cipher is the same as the alphabet of the text in clear but shifted 3 spaces to the right module n, with n the number of letters in the same

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}

\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}

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} become

\tiny\begin{pmatrix} 15& 7& 21& 21& 3& 9& 7& 21& 7& 16& 22& 1& 7& 21& 22& 7& 20& 6& 3& 1 \\ P& H& V& V& D& J& H& V& H& Q& W& B& H& V& W& H& U& G& D& B \\ \end{pmatrix}

So the encrypted message is:

M=PHVVDJHVHQWBHVWHUGDB

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}

\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

This system of encryption, simple, appropriate and even pretty ingenious for the time, presents a level of security very weak

Cryptanalysis of the encryption of Caesar

In the event a substitution is fixed for each character of the alphabet in clear by a single character of the alphabet of the cipher, the cryptogram will be able to easily break using statistical techniques of the language, always and when we have a sufficient amount of cipher text

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 n = 26, there are only 25 possible combinations of alphabets, therefore H(K)=\log_2{25}=4,64

As the redundancy D was equal to 4.03 then you have to N=\frac{H(K)}{D}\approx\frac{4,64}{4,03}\approx 1,15. Therefore, we need a minimum of 2 characters

An elementary form of cryptanalysis is to write under the text encryption all the combinations of phrases, with or without meaning, which are obtained by applying to said cryptogram displacement of 1, \cdots, n-1 characters, n being the number of characters of the alphabet used. One of these combinations will give with the clear text and this will be true regardless of the value assigned to the constant displacement

b Cipher
1 QIWWEKIWIRXCIWXIVHEC
2 RJXXFLJXJSYDJXYJWIFD
3 SKYYGMKYKTZEKYZKXJGE
4 TLZZHNLZLUAFLZALYKHF
5 UMAAIOMAMVBGMABMZLIG
6 VNBBJPNBNWCHNBCNAMJH
7 WOCCKQOCOXDIOCDOBNKI
8 XPDDLRPDPYEJPDEPCOLJ
9 YQEEMSQEQZFKQEFQDPMK
10 ZRFFNTRFRAGLRFGREQNL
11 ASGGOUSGSBHMSGHSFROM
12 BTHHPVTHTCINTHITGSPN
13 CUIIQWUIUDJOUIJUHTQO
14 CUIIQWUIUDJOUIJUHTQO
15 EWKKSYWKWFLQWKLWJVSQ
16 FXLLTZXLXGMRXLMXKWTR
17 GYMMUAYMYHNSYMNYLXUS
18 HZNNVBZNZIOTZNOZMYVT
19 IAOOWCAOAJPUAOPANZWU
20 JBPPXDBPBKQVBPQBOAXV
21 KCQQYECQCLRWCQRCPBYW
22 LDRRZFDRDMSXDRSDQCZX
23 MESSAGESENTYESTERDAY
24 NFTTBHFTFOUZFTUFSEBZ
25 OGUUCIGUGPVAGUVGTFCA

I could easy say that a system of encryption by substitution monoalfabética as he Cesar presents a minimal level of security in both support of romero, we have been how to a pencil, and a little bit of patience and support to make him box before, nothing out of this world

This weakness is due to that the number of possible offsets is very small, counting only with the 25 values that correspond to the characters of the alphabet; that is, it is true that 1\leq b\leq 25since a displacement equal to zero or a multiple of twenty-six would be equal to that transmit in the clear

Is to be fulfilled by both the following decryption operation is D from a And encryption in the ring n:

D_b=E_{n-b}\Rightarrow D_3=E_{26-3}=E_{23}

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

Encryption of Polybius

Encryption of Polybius

The Greek historian Polybius (203-120 B. C.), created a system of sending messages by means of torches

The method consisted essentially in the creation of a square matrix of 5 \times 5 such as the following

\begin{pmatrix}&1&2&3&4&5\\1&A&B&C&D&E\\2&F&G&H&I/J&K\\3&L&M&N&O&P\\4&Q&R&S&T&U\\5&V&W&X&Y&Z\end{pmatrix}

The message is represented by numbers that form the row and column whose intersection gives as a result the letter you want to send

While the method of Polybius does not initially had a purpose cryptographic, yes that is the base of later systems, and the first known case of replacement monoalfabética multiliteral

A variant of the encryption of Polybius, used by the communists in the Spanish civil war consisted of generating a table with three rows of ten columns

The first row had no numbering, and the second and third rows are ultimately respectively with two of the unused numbers in the columns of the first row

The columns are ultimately with a permutation of the digits from zero to nine

The encryption process consisted in putting a word of eight or fewer different letters in the first row

In this word were removed the letters repeated and the rest, until you complete the alphabet, arranged in two rows

Encryption is similar to that of Polybius, but here the letters can be encoded as one or two numbers

Example of the alternative communist of the encryption of Polybius

The Spanish communists had to send the following message, which would not that franco's troops interceptasen

C=EN PIE FAMELICA LEGION

Taking as a key:

K=FUSIL

Using the following table

\tiny\begin{pmatrix}&8&3&0&2&4&6&1&7&5&9\\&F&U&S&I&L\\5&A&B&C&D&E&G&H&J&K&M\\1&N/\widetilde{N}&O&P&Q&R&T&V&X&Y&Z \end{pmatrix}

So we is that the encrypted message is:

M=54 18 10 2 54 8 58 59 54 4 2 50 58 4 54 56 2 13 18

We can decipher the M previous

We go to the table of encryption, if we have two numbers, check which is your row and the second corresponds to the column

The row of the intersection of both will be the letter that will be used in the message decryption

If we have a figure, is the one corresponding to the column and the row is the one corresponding to the key

There may be confusion in the case of 18, because they share a common position of the N and the Ñ, all depends on the context of the message (in this case the N)

We will repeat the process until you get the message clear

Getting the original C:

C=ENPIEFAMELICALEGION

Vigenère cipher

Vigenère cipher

The Vigenére cipher is an encryption based on different series of characters or letters of Caesar's encryption forming these characters a table, called a Vigenére table, which is used as a key

The Vigenère cipher is a cipher substitution simple polyalphabetic

The first polyalphabetic was the call encryption encryption Alberti, created by Leon Battista Alberti around 1467

To facilitate the calculations we took advantage of a metal disk that allowed you to easily switch between the different scripts available

The system of Alberti, only changing between alphabets after several words, and the changes are indicated by writing the letter of the corresponding alphabet in the encrypted message

Later, in 1508, Johannes Trithemius, in his work Poligraphia, invented the tabula recta, which is basically the table of Vigenère

Trithemius, however, only provided a progressive, rigid and predictable system for switching between alphabets

What is now known as the Vigenère cipher was originally described in 1533 by Giovan Battista Belasso in his book The figure of the Sig. who built the encryption based on the tabula recta of Trithemius, but added a key repeatedly to switch each character between the different alphabets

Blaise de Vigenère published his description of an encryption of an autoclave similar, but more robust, before the reign of Henry III of France, in 1586

Later, in the 19th century, the invention of encryption ceased to be attributed to Vigenére

The cifrado Vigenère ganó una gran reputación por ser excepcionalmente robusto

Even the writer and mathematician Charles Lutwidge Dodgson (better known as Lewis Carroll) said that the encryption Vigenère was unbreakable in the article The Alphabet Cipher for a magazine of children

In 1917, Scientific American he described the encryption Vigenère as impossible to break

This reputation was maintained until the Kasiski method resolved the encryption in the 19th century and some skilled cryptanalysts were able to break it several times in the 16th century

The cipher Vigenère is simple enough if it is used with disk encryption. The confederate States of America, for example, used a disk encryption to implement encryption Vigenère during the american Civil War

Messages confederates were little secrets, as the members of the Union used to decrypt the messages

Gilbert Vernam tried to fix the encryption (creating the encryption Vernam-Vigenère in 1918), but no matter what you do, the encryption is still vulnerable to cryptanalysis (Not to be confused with the encryption Vernam)

Throughout this article for simplicity I will use standard English alphabet 26 letters:

\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}

And the next box corresponding to the Vigenère cipher

\tiny\begin{pmatrix}&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\\A&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\\B&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&A\\C&C&D&E&F&G&H&I&J&K&L&M&N&O&P&Q&R&S&T&U&V&W&X&Y&Z&A&B\\D&D&E&F&G&H&I&J&K&L&M&N&O&P&Q&R&S&T&U&V&W&X&Y&Z&A&B&C\\E&E&F&G&H&I&J&K&L&M&N&O&P&Q&R&S&T&U&V&W&X&Y&Z&A&B&C&D\\F&F&G&H&I&J&K&L&M&N&O&P&Q&R&S&T&U&V&W&X&Y&Z&A&B&C&D&E\\G&G&H&I&J&K&L&M&N&O&P&Q&R&S&T&U&V&W&X&Y&Z&A&B&C&D&E&F\\H&H&I&J&K&L&M&N&O&P&Q&R&S&T&U&V&W&X&Y&Z&A&B&C&D&E&F&G\\I&I&J&K&L&M&N&O&P&Q&R&S&T&U&V&W&X&Y&Z&A&B&C&D&E&F&G&H\\J&J&K&L&M&N&O&P&Q&R&S&T&U&V&W&X&Y&Z&A&B&C&D&E&F&G&H&I\\K&K&L&M&N&O&P&Q&R&S&T&U&V&W&X&Y&Z&A&B&C&D&E&F&G&H&I&J\\L&L&M&N&O&P&Q&R&S&T&U&V&W&X&Y&Z&A&B&C&D&E&F&G&H&I&J&K\\M&M&N&O&P&Q&R&S&T&U&V&W&X&Y&Z&A&B&C&D&E&F&G&H&I&J&K&L\\N&N&O&P&Q&R&S&T&U&V&W&X&Y&Z&A&B&C&D&E&F&G&H&I&J&K&L&M\\O&O&P&Q&R&S&T&U&V&W&X&Y&Z&A&B&C&D&E&F&G&H&I&J&K&L&M&N\\P&P&Q&R&S&T&U&V&W&X&Y&Z&A&B&C&D&E&F&G&H&I&J&K&L&M&N&O\\Q&Q&R&S&T&U&V&W&X&Y&Z&A&B&C&D&E&F&G&H&I&J&K&L&M&N&O&P\\R&R&S&T&U&V&W&X&Y&Z&A&B&C&D&E&F&G&H&I&J&K&L&M&N&O&P&Q\\S&S&T&U&V&W&X&Y&Z&A&B&C&D&E&F&G&H&I&J&K&L&M&N&O&P&Q&R\\T&T&U&V&W&X&Y&Z&A&B&C&D&E&F&G&H&I&J&K&L&M&N&O&P&Q&R&S\\U&U&V&W&X&Y&Z&A&B&C&D&E&F&G&H&I&J&K&L&M&N&O&P&Q&R&S&T\\V&V&W&X&Y&Z&A&B&C&D&E&F&G&H&I&J&K&L&M&N&O&P&Q&R&S&T&U\\W&W&X&Y&Z&A&B&C&D&E&F&G&H&I&J&K&L&M&N&O&P&Q&R&S&T&U&V\\X&X&Y&Z&A&B&C&D&E&F&G&H&I&J&K&L&M&N&O&P&Q&R&S&T&U&V&W\\Y&Y&Z&A&B&C&D&E&F&G&H&I&J&K&L&M&N&O&P&Q&R&S&T&U&V&W&X\\Z&Z&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\end{pmatrix}

The encryption can be expressed with the following formula:

M(X_i)=(X_i+K_i-1)\pmod{L}

Where X_i is the letter in position i of the text to encrypt, K_i it is the character of the corresponding key to X_i because they are in the same position, and L is the size of the alphabet. In this case L = 26

To decrypt we will perform the reverse operation:

D(C_i)=(C_i-K_i+1)\pmod{L}

Where C_i is the character at position i of cipher text, K_i comes to be the character of the corresponding key to C_i, and L the size of the alphabet

Keep in mind that the same letter in the clear text can correspond to different letters in the ciphered text

Example of Vigenère cipher

We have the following message that we want to encrypt:

C=MESSAGE SENT YESTERDAY

L = 26 because we're going to use the English alphabet

We take as key:

K = I’M BORED

It is advisable that the key is larger than the message. We put together a message and a key, repeating as many times as necessary the key

\tiny\begin{pmatrix} M& E& S& S& A& G& E& S& E& N& T& Y& E& S& T& E& R& D& A& Y \\ I& M& B& O& R& E& D& I& M& B& O& R& E& D& I& M& B& O& R& E \\ \end{pmatrix}

We go to the table of encryption, and we take the row of the first letter of the key word in the table of Vigénere and the column of the first letter of the message

The intersection of both will be the letter that will be used for encryption

We will repeat the process until you get the encrypted message

So we is that the encrypted message is:

M=UQTGRKHAQOHPIVBQSRRC

We can decipher the M previous

We go to the table of encryption, and we take the column of the first letter of the key word in the table of Vigénere and looking for the first letter of the message

The row of the intersection of both will be the letter that will be used in the message decryption

We will repeat the process until you get the message clear

\tiny\begin{pmatrix} I& M& B& O& R& E& D& I& M& B& O& R& E& D& I& M& B& O& R& E \\ U& Q& T& G& R& K& H& A& Q& O& H& P& I& V& B& Q& S& R& R& C \\ \end{pmatrix}

Getting the original C:

C=MESSAGESENTYESTERDAY

Encryption of Gronsfeld

Encryption of Gronsfeld

The encryption of Gronsfeld emerged as an enhancement to the encryption, Vigenère, as that was susceptible to an analysis cryptic with certain conditions laid down. To evaluate some features, it was possible to define the length of the key, and then, when parsing the rows of letters, enciphered by the same row of the table, one could employ a standard method based on the frequency of certain letters of the language

The first to make a successful attack in the modification of the encryption Vigenère in 1854, was Charles Babbage, a pioneer of computing, but the analysis was released nine months later by another researcher, Friedrich Kasiski

Strange as it may seem, this helped to strengthen it, resulting in the encryption of Gronsfeld. One of the improvements was the use of the word key, which is equal to the length of the message itself, thus eliminating the possibility of a frequency analysis

However, this update brought another vulnerability: the use of text-sensitive as a key phrase, contributed to the criptoanalista statistical information about the key, serving as a track to the point of wanting to decipher the text

As it is based on the encryption Vigenère, is also a substitution encryption simple polyalphabetic. This means that using more than one alphabet cipher to put in the key the message and that it changes from one to the other as it passes from a letter of the clear text to another. That is to say that you should be a set of alphabets encrypted and a way to match each letter of the original text with one of them

The number of alphabets encryption is limited to 10, coded from 0 to 9 and the key is generated with a combination of these digits, without repetitions. Alters the frequency of the letters of the text, since for example the letter more current in English, E, is encrypted differently according to their position in the original text

Throughout this article for simplicity I will use standard English alphabet 26 letters:

\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}

And the next box corresponding to the encryption of Gronsfeld

\tiny\begin{pmatrix}&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\\0&C&D&E&F&G&H&I&J&K&L&M&N&O&P&Q&R&S&T&U&V&W&X&Y&Z&A&B\\1&D&E&F&G&H&I&J&K&L&M&N&O&P&Q&R&S&T&U&V&W&X&Y&Z&A&B&C\\2&F&G&H&I&J&K&L&M&N&O&P&Q&R&S&T&U&V&W&X&Y&Z&A&B&C&D&E\\3&H&I&J&K&L&M&N&O&P&Q&R&S&T&U&V&W&X&Y&Z&A&B&C&D&E&F&G\\4&L&M&N&O&P&Q&R&S&T&U&V&W&X&Y&Z&A&B&C&D&E&F&G&H&I&J&K\\5&N&O&P&Q&R&S&T&U&V&W&X&Y&Z&A&B&C&D&E&F&G&H&I&J&K&L&M\\6&R&S&T&U&V&W&X&Y&Z&A&B&C&D&E&F&G&H&I&J&K&L&M&N&O&P&Q\\7&T&U&V&W&X&Y&Z&A&B&C&D&E&F&G&H&I&J&K&L&M&N&O&P&Q&R&S\\8&X&Y&Z&A&B&C&D&E&F&G&H&I&J&K&L&M&N&O&P&Q&R&S&T&U&V&W\\9&C&D&E&F&G&H&I&J&K&L&M&N&O&P&Q&R&S&T&U&V&W&X&Y&Z&A&B\end{pmatrix}

this box is not the only possible one, it has been used as an offset to the first 9 prime numbers, and may use another method to create the 10 alphabets

Example of encryption of Gronsfeld

We have the following message that we want to encrypt:

C=MESSAGE SENT YESTERDAY

We take as key:

K = 1203456987

It is advisable that the key is larger than the message. We put together a message and a key, repeating as many times as necessary the key

\tiny\begin{pmatrix} M& E& S& S& A& G& E& S& E& N& T& Y& E& S& T& E& R& D& A& Y \\ 1& 2& 0& 3& 4& 5& 6& 9& 8& 7& 1& 2& 0& 3& 4& 5& 6& 9& 8& 7 \\ \end{pmatrix}

We go to the table of encryption, and we take the row of the first key number in the table of Gronsfeld and the column of the first letter of the message. The intersection of both will be the letter that will be used for encryption. We will repeat the process until you get the encrypted message

So we is that the encrypted message is:

M=PJUZLTVUBGWDGZERIFXR

We can decipher the M previous

We go to the table of encryption, and we take the row of the first key number in the table of Gronsfeld and looking for the first letter of the message. The row of the intersection of both will be the letter that will be used in the decrypted message. We will repeat the process until you get the message clear

\tiny\begin{pmatrix} 1& 2& 0& 3& 4& 5& 6& 9& 8& 7& 1& 2& 0& 3& 4& 5& 6& 9& 8& 7 \\ P& J& U& Z& L& T& V& U& B& G& W& D& G& Z& E& R& I& F& X& R \end{pmatrix}

Getting the original C:

C=MESSAGESENTYESTERDAY

Hill cipher

Hill cipher

This system is based on the linear algebra and is very important in the history of cryptography. It was Invented by Lester S. Hill in 1929, and was the first cryptographic system polyalphabetic working with more than three symbols simultaneously

This system is polyalphabetic because it may be that a same character in a message to be sent is encrypted in two different characters in the encrypted message

I would like to start with a very simple system that can be explained mathematically speaking using modular arithmetic. Throughout this article I will use for simplicity the alphabet in standard English 26-letter:

\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}

Choose an integer d that determines blocks of d elements, which will be treated as a vector of d dimensions. Randomly, we choose a matrix of d × d elements which will be the key to be used. The elements of the matrix d × d will be integers between 0 and 25, in addition the matrix M must be invertible in \mathbb{Z}^n_{26}

For the encryption, the text is divided into blocks of d elements which are multiplied by the matrix d × d. As well M\cdot P_i \equiv C \pmod{26} where we have assigned the number 0, B 1, ... , Z to 25, and \pmod{26} indicates that we should take the remainder of dividing by 26 (in C language we use the % operator ) M is the matrix d × d, C is the ciphertext and P the original

Example of Hill cipher

CODIGO we break the structure into blocks of 3 characters each (in this case d = 3), eliminating punctuation marks, if any, and we get the numerical equivalents of these letters

P_1=COD=\begin{pmatrix} 2 \\ 14 \\ 3 \end{pmatrix}, P_2=IGO=\begin{pmatrix} 8 \\ 6 \\ 14 \end{pmatrix}

We chose M=\begin{pmatrix} 5& 17& 20 \\ 9& 23& 3& \\ 2& 11& 13 \end{pmatrix} as the keys array

Before applying the encryption, we must ensure that M is invertible \mod{26}. There is a relatively simple way to find this out through the calculation of the determinant. If the determinant of the matrix is 0, or has common factors with the modulus (in the case of 26 the factors are 2 and 13), then the array cannot be used. To be 2 one of the factors of 26 many arrays may not be used (will not serve them all in that its determinant is 0, a multiple of 2 or a multiple of 13)

\det(M) = \begin{vmatrix} 5& 17& 20 \\ 9& 23& 3& \\ 2& 11& 13 \end{vmatrix} = 5 \cdot(23 \cdot 13 - 3 \cdot 11) - 17 \cdot (9 \cdot 13 - 3 \cdot 2) + 20 \cdot (9 \cdot 11 - 23 \cdot 2) =
= 1215 - 1734 + 1060 = 503

Now we check \pmod{26}:

503 = 9\pmod{26}

The matrix A is invertible in \mod{26}because 26 and 9 are coprimos

We calculate the first block:

M\cdot P_1=\begin{pmatrix} 5& 17& 20 \\ 9& 23& 3& \\ 2& 11& 13 \end{pmatrix}\cdot \begin{pmatrix} 2 \\ 14 \\ 3 \end{pmatrix} = \begin{pmatrix} 308 \\ 349 \\ 197 \end{pmatrix}

\begin{pmatrix} 308 \\ 349 \\ 197 \end{pmatrix} = \begin{pmatrix} 22 \\ 11 \\ 15 \end{pmatrix}\pmod{26}

\begin{pmatrix} 22 \\ 11 \\ 15 \end{pmatrix} = WLP

So the encrypted message block one is:

C_1=WLP

We calculate the second block:

M\cdot P_2=\begin{pmatrix} 5& 17& 20 \\ 9& 23& 3& \\ 2& 11& 13 \end{pmatrix}\cdot \begin{pmatrix} 8 \\ 6 \\ 14 \end{pmatrix} = \begin{pmatrix} 422 \\ 252 \\ 264 \end{pmatrix}

\begin{pmatrix} 422 \\ 252 \\ 264 \end{pmatrix} = \begin{pmatrix} 6 \\ 18 \\ 4 \end{pmatrix}\pmod{26}

\begin{pmatrix} 6 \\ 18 \\ 4 \end{pmatrix} = GSE

So the encrypted message block one is:

C_2=GSE

We add both messages encrypted to obtain the encrypted message C:

C=WLPGSE

We can decipher the C above, the method is the same, but we need to calculate M^{-1}. To do this we calculate from this formula:

M^{-1}=C^t\cdot (\det(M))^{-1}

Where C^t is the matrix of cofactors of M transposed and (\det(M))^{-1} should be done as \mod{26}, which in this case is 3 since:

9\pmod{26} \cdot 3\pmod{26}=27 \pmod{26}=1 \pmod{26}

We calculate the cofactors of M

C_{1 1}= + \begin{vmatrix} 23& 3 \\ 11& 13 \end{vmatrix} C_{1 2}= - \begin{vmatrix} 9& 3 \\ 2& 13 \end{vmatrix} C_{1 3}= + \begin{vmatrix} 9& 23 \\ 2& 11 \end{vmatrix}

C_{2 1}= - \begin{vmatrix} 17& 20 \\ 11& 13 \end{vmatrix} C_{2 2}= + \begin{vmatrix} 5& 20 \\ 2& 13 \end{vmatrix} C_{2 3}= - \begin{vmatrix} 5& 17 \\ 2& 11 \end{vmatrix}

C_{3 1}= + \begin{vmatrix} 17& 20 \\ 23& 3 \end{vmatrix} C_{3 2}= - \begin{vmatrix} 5& 20 \\ 9& 3 \end{vmatrix} C_{3 3}= + \begin{vmatrix} 5& 17 \\ 9& 23 \end{vmatrix}

C=\begin{pmatrix} 266& -111& 53 \\ -1& 25& -21& \\ -409& 165& -38 \end{pmatrix} C^t= \begin{pmatrix} 266& -1& -409 \\ -111& 25& 165 \\ 53& -21& -38 \end{pmatrix}

Now we apply the formula in reverse:

M^{-1}=C^t\cdot (\det(M))^{-1}=\begin{pmatrix} 266& -1& -409 \\ -111& 25& 165 \\ 53& -21& -38 \end{pmatrix} \cdot 3=\begin{pmatrix} 798& -3& -1227 \\ -333& 75& 495 \\ 159& -63& -114 \end{pmatrix}

M^{-1}\pmod{26}=\begin{pmatrix} 798& -3& -1227 \\ -333& 75& 495 \\ 159& -63& -114 \end{pmatrix} \pmod{26} =\begin{pmatrix} 18& 23& 21 \\ 5& 23& 1 \\ 3& 15& 16 \end{pmatrix}

We calculate the first block:

M\cdot P_1=\begin{pmatrix} 18& 23& 21 \\ 5& 23& 1& \\ 3& 15& 16 \end{pmatrix}\cdot \begin{pmatrix} 22 \\ 11 \\ 15 \end{pmatrix} = \begin{pmatrix} 964 \\ 378 \\ 471 \end{pmatrix}

\begin{pmatrix} 964 \\ 378 \\ 471 \end{pmatrix} = \begin{pmatrix} 2 \\ 14 \\ 3 \end{pmatrix}\pmod{26}

\begin{pmatrix} 2 \\ 14 \\ 3 \end{pmatrix} = COD

So the encrypted message block one is:

P_1=COD

We calculate the second block:

M\cdot P_2=\begin{pmatrix} 18& 23& 21 \\ 5& 23& 1& \\ 3& 15& 16 \end{pmatrix}\cdot \begin{pmatrix} 6 \\ 18 \\ 4 \end{pmatrix} = \begin{pmatrix} 606 \\ 448 \\ 352 \end{pmatrix}

\begin{pmatrix} 606 \\ 448 \\ 352 \end{pmatrix} = \begin{pmatrix} 8 \\ 6 \\ 14 \end{pmatrix}\pmod{26}

\begin{pmatrix} 8 \\ 6 \\ 14 \end{pmatrix} = IGO

So the encrypted message block one is:

P_2=IGO

We add both messages encrypted to obtain the encrypted message C:

P=CODIGO