The simplest ciphers: a description of popular codes and ciphers

The need for encryption of correspondence arose in the ancient world, and ciphers of simple replacement appeared. Encrypted messages determined the fate of many battles and influenced the course of history. Over time, people invented more advanced encryption methods.

Code and cipher are, by the way, different concepts. The first means replacing each word in the message with a code word. The second is to encrypt each symbol of information using a specific algorithm.

After mathematics took up the coding of information and the theory of cryptography was developed, scientists discovered many useful properties of this applied science. For example, decoding algorithms have helped solve dead languages ​​such as Ancient Egyptian or Latin.

Steganography

Steganography is older than encryption and encryption. This art appeared a very long time ago. It literally means “hidden letter” or “secret writing”. Although steganography does not quite correspond to the definitions of a code or cipher, it is intended to hide information from prying eyes.

Steganography or Cryptography

Steganography is the simplest cipher. Typical examples are swallowed notes covered with wax, or a message on a shaved head that hides beneath grown hair. The clearest example of steganography is the method described in many English (and not only) detective books, when messages are transmitted through a newspaper, where letters are subtly marked.

The main disadvantage of steganography is that an attentive outsider can notice it. Therefore, so that the secret message is not easily readable, together with steganography, encryption and coding methods are used.

ROT1 and Caesar's code

The name of this cipher is ROTate 1 letter forward, and it is known to many students. It is a simple replacement cipher. Its essence is that each letter is encrypted by shifting 1 letter forward in the alphabet. A -> B, B -> C, ..., I -> A. For example, we encrypt the phrase “our Nastya is crying loudly” and get “general Obtua dsnlp rmbscheu”.

The cipher ROT1 can be generalized to an arbitrary number of offsets, then it is called ROTN, where N is the number by which the encryption of letters should be shifted. In this form, the cipher has been known since ancient times and is called the Caesar code.

Cyrillic disk for Caesar's cipher

Caesar's cipher is very simple and fast, but it is a cipher of a simple single permutation and therefore is easily cracked. Having a similar disadvantage, it is only suitable for children's pranks.

Transpositional or permutation ciphers

These types of ciphers of simple permutation are more serious and were actively used not so long ago. During the Civil War in the United States and World War I, it was used to transmit messages. Its algorithm is to rearrange the letters in places - write the message in the reverse order or rearrange the letters in pairs. For example, we encrypt the phrase “Morse code is also a cipher” -> “Akubza Morocco - hedgehog fish”.

With a good algorithm that determined arbitrary permutations for each character or their group, the cipher became resistant to simple hacking. But! Only in due time. Since the cipher is easily cracked by simple brute force or dictionary matching, today any smartphone can handle its decryption. Therefore, with the advent of computers, this cipher also moved into the category of children.

Morse code

The ABC is a means of exchanging information and its main task is to make messages simpler and more understandable for transmission. Although this is contrary to what encryption is for. Nevertheless, it works like the simplest ciphers. In the Morse system, each letter, number and punctuation mark has its own code, made up of a group of dashes and dots. When transmitting a message by telegraph, dashes and dots indicate long and short signals.

Cyrillic and latin morse code

The telegraph and Morse code ... Morse was the first to patent “his” invention in 1840, although similar devices were invented before him both in Russia and England. But who cares now ... The telegraph and Morse code had a very big impact on the world, allowing almost instantly transmit messages over continental distances.

Mono-Alphabetical Replacement

The ROTN and Morse code described above are representative of mono-alphabetic replacement fonts. The prefix "mono" means that during encryption, each letter of the original message is replaced by a different letter or code from a single encryption alphabet.

Deciphering ciphers is a simple replacement is not difficult, and this is their main drawback. They guess a simple search or frequency analysis. For example, it is known that the most used letters of the Russian language are “o”, “a”, “and”. Thus, it can be assumed that in the ciphertext the letters that occur most often mean either “o”, or “a”, or “and”. Based on such considerations, the message can be decrypted even without busting by computer.

It is known that Mary I, Queen of Scotland from 1561 to 1567, used a very complex cipher of mono-alphabetic replacement with several combinations. And yet her enemies were able to decipher the messages, and there was enough information to sentence the queen to death.

Gronsfeld cipher, or polyalphabetic substitution

Simple ciphers are considered useless by cryptography. Therefore, many of them have been finalized. The Gronsfeld cipher is a modification of Caesar's cipher. This method is much more resistant to hacking and consists in the fact that each character of the encoded information is encrypted using one of different alphabets, which are cyclically repeated. We can say that this is a multidimensional application of the simplest replacement cipher. In fact, the Gronsfeld cipher is very similar to the Vigenère cipher discussed below.

ADFGX Encryption Algorithm

This is the most famous cipher of the First World War, used by the Germans. The cipher got its name because the encryption algorithm led all cipher programs to alternate these letters. The choice of the letters themselves was determined by their convenience when transmitting via telegraph lines. Each letter in the code is represented by two. Consider a more interesting version of the ADFGX square, which includes numbers and is called ADFGVX.

ADFGVX
AJQA5HD
D2ERV9Z
F8YINKV
GUPBF6O
V4GXS3T
XWLQ7C0

The ADFGX squaring algorithm is as follows:

  1. We take random n letters to denote columns and rows.
  2. Build the matrix N x N.
  3. We enter the alphabet, numbers, signs randomly scattered across the cells in the matrix.

Let's make a similar square for the Russian language. For example, create a square ABVGD:

ABINGD
AHERNB / bAI / Y
BHV / FG / C3D
INW / SBLXI
GRMABOUTYUP
DFTTsSAt

This matrix looks strange, as a row of cells contains two letters each. This is permissible, the meaning of the message is not lost. It can be easily restored. We encrypt the phrase “Compact cipher” using this table:

12345678910eleven12thirteen14
PhraseTOABOUTMPATOTNSThWANDFR
Cipherbvguardsgbwhereagbvdbabdghellwahellbbha

Thus, the final encrypted message looks like this: "bvgvgbgdagbvdbabdgvdvaadbbga". Of course, the Germans conducted a similar line through several more ciphers. And in the end, an encrypted message is very resistant to hacking.

Vigenere Cipher

This cipher is an order of magnitude more resistant to hacking than mono-alphabetic ones, although it is a cipher of simple text replacement. However, thanks to a robust algorithm, it was long considered impossible to crack. Its first references date back to the 16th century. Vizhener (French diplomat) is mistakenly considered its inventor. To better understand what is at stake, consider the Vigenere table (Vigenere square, tabula recta) for the Russian language.

Vigenere table with the Russian alphabet

We proceed to encrypt the phrase "Kasperovich is laughing." But for encryption to succeed, you need a keyword - let it be “password”. Now let's start encryption. To do this, we write the key so many times so that the number of letters from it matches the number of letters in the encrypted phrase, by repeating the key or trimming:

12345678910eleven12thirteen14fifteen1617
Phrase:TOAFROMPERABOUTINANDHFROMMEETFROMI
KeyPARABOUTLBPARABOUTLBPARABOUTL

Now, according to the Vigenère table, as on the coordinate plane, we are looking for a cell that is the intersection of pairs of letters, and we get: K + P = b, A + A = B, C + P = B, etc.

12345678910eleven12thirteen14fifteen1617
Cipher:BBINYUFROMNYUGUFEThXFGAL

We get that "Kasperovich is laughing" = " " ".

Hacking the Vigenere cipher is so difficult, because for the operation of frequency analysis it is necessary to know the length of the keyword. Therefore, hacking is to randomly cast the length of the keyword and try to crack the secret message.

It should also be mentioned that in addition to a completely random key, a completely different Vigenere table can be used. In this case, the Vigenère square consists of a line-by-line Russian alphabet with an offset of one. Which sends us to the cipher ROT1. And just like in Caesar’s cipher, the displacement can be any. Moreover, the order of letters should not be alphabetical. In this case, the table itself can be a key, without knowing which it will be impossible to read the message, even knowing the key.

Codes

These codes consist of correspondences for each word of a separate code. To work with them, so-called code books are needed. In fact, this is the same dictionary, only containing translations of words into codes. A typical and simplified example of codes is the ASCII table - an international cipher of simple characters.

ASCII Code Table

The main advantage of codes is that it is very difficult to decrypt them. Frequency analysis almost does not work when they are cracked. The weakness of the codes is, in fact, the books themselves. First, their preparation is a complex and expensive process. Secondly, for enemies they turn into a coveted object and the interception of even parts of the book forces you to change all the codes completely.

In the 20th century, many states used codes to transmit sensitive data, changing the codebook after a certain period. And they actively hunted for books of neighbors and opponents.

"Enigma"

Everyone knows that Enigma is the main encryption machine of the Nazis during World War II. The Enigma structure includes a combination of electrical and mechanical circuits. How the cipher will turn out depends on the initial configuration of Enigma. At the same time, Enigma automatically changes its configuration during operation, encrypting a single message in several ways throughout its length.

In contrast to the simplest ciphers, Enigma produced trillions of possible combinations, which made breaking encrypted information almost impossible. In turn, the Nazis prepared a certain combination for each day, which they used on a particular day to transmit messages. Therefore, even if the Enigma fell into the hands of the enemy, it did not contribute to decrypting messages without introducing the desired configuration every day.

Nazi encryption machine Enigma

Hack Enigma actively tried throughout Hitler's military campaign. In England in 1936, one of the first computing devices (Turing machine) was built for this, which became the prototype of computers in the future. His task was to simulate the work of several dozen Enigms simultaneously and run through them intercepted Nazi messages. But even the Turing machine only occasionally succeeded in breaking the message.

Public Key Encryption

The most popular of the encryption algorithms, which is used universally in technology and computer systems. Its essence is, as a rule, in the presence of two keys, one of which is transmitted publicly, and the second is secret (private). The public key is used to encrypt the message, and the secret key is used to decrypt.

Public Key Encryption Algorithm

The role of the public key is most often played by a very large number, for which there are only two divisors, not counting the unit and the number itself. Together, these two dividers form a secret key.

Consider a simple example. Let the public key be 905. Its divisors are the numbers 1, 5, 181 and 905. Then the secret key will be, for example, the number 5 * 181. Will you say too simple? But what if the role of the public number is a number with 60 characters? It is mathematically difficult to calculate the divisors of a large number.

As a more lively example, imagine that you are withdrawing money from an ATM. When reading a card, personal data is encrypted with a specific public key, and on the bank side, the information is decrypted with a secret key. And this public key can be changed for each operation. But there are no ways to quickly find key divisors when intercepting it.

Font Resistance

The cryptographic strength of the encryption algorithm is the ability to withstand hacking. This option is the most important for any encryption. Obviously, a simple replacement cipher, decryption of which can be mastered by any electronic device, is one of the most unstable.

To date, there are no uniform standards by which to evaluate the strength of the cipher. This is a laborious and lengthy process. However, there are a number of commissions that have set standards in this area. For example, the minimum requirements for the Advanced Encryption Standart or AES encryption algorithm developed by NIST USA.

For reference: the Vernam cipher is recognized as the most resistant to cracking code. Moreover, its advantage is that by its algorithm it is the simplest cipher.

Source: https://habr.com/ru/post/F31956/


All Articles