Simple ciphers: description of popular codes and ciphers

Table of contents:

Simple ciphers: description of popular codes and ciphers
Simple ciphers: description of popular codes and ciphers
Anonim

The need to encrypt correspondence arose in the ancient world, and simple substitution ciphers appeared. Encrypted messages determined the fate of many battles and influenced the course of history. Over time, people invented more and 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 began to encode information and the theory of cryptography was developed, scientists discovered many useful properties of this applied science. For example, decoding algorithms have helped unravel dead languages such as ancient Egyptian or Latin.

Steganography

Steganography is older than coding and encryption. This art has been around for a very long time. It literally means "hidden writing" or "cipher writing". Although steganography does not quite meet the definitions of a code or cipher, it is intended to hide information from strangers.eye.

Steganography or cryptography
Steganography or cryptography

Steganography is the simplest cipher. Swallowed notes covered in wax are typical examples, or a message on a shaved head that hides under 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 inconspicuously marked.

The main disadvantage of steganography is that an attentive stranger can notice it. Therefore, in order to prevent the secret message from being easily read, encryption and coding methods are used in conjunction with steganography.

ROT1 and Caesar cipher

The name of this cipher is ROTate 1 letter forward, and it is known to many schoolchildren. It is a simple substitution cipher. Its essence lies in the fact that each letter is encrypted by shifting alphabetically by 1 letter forward. A -> B, B -> C, …, Z -> A. For example, we encrypt the phrase "our Nastya cries loudly" and we get "general Obtua dspnlp rmbsheu".

The ROT1 cipher 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 cipher".

Cyrillic disk for Caesar's cipher
Cyrillic disk for Caesar's cipher

Caesar cipher is very simple and fast, but it is a simple single permutation cipher and is therefore easy to break. Having such a disadvantage, it is only suitable for childish pranks.

Transpositional or permutation ciphers

These types of simple permutation ciphers are more serious and were actively used not so long ago. During the American Civil War and World War I, it was used to send messages. His algorithm consists in rearranging the letters in places - write the message in reverse order or rearrange the letters in pairs. For example, let's encrypt the phrase "Morse code is also a cipher" -> "akubza ezrom - hedgehog rfish".

With a good algorithm that determined arbitrary permutations for each character or group of them, the cipher became resistant to simple cracking. But! Only in due time. Since the cipher is easily broken 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's.

Morse code

The alphabet is a medium of information exchange and its main task is to make messages easier and more understandable for transmission. Although this is contrary to what encryption is intended 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 sending a message using the telegraph, dashes and dots represent long and short signals.

Cyrillic and Latin in Morse code
Cyrillic and Latin in Morse code

Telegraph and Morse code… Morse was the one who first patented "his" invention in 1840, although similar devices had been invented in Russia and England before him. But who cares now … Telegraph and alphabetMorse code had a very big impact on the world, allowing almost instantaneous transmission of messages over continental distances.

Monoalphabetic substitution

The ROTN and Morse code described above are examples of monoalphabetic replacement fonts. The prefix "mono" means that during encryption, each letter of the original message is replaced by another letter or code from the only encryption alphabet.

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

It is known that Mary I, Queen of Scots from 1561 to 1567, used a very complex monoalphabetic substitution cipher with several combinations. Yet her enemies were able to decipher the messages, and the information was enough to sentence the queen to death.

Gronsfeld cipher, or polyalphabetic substitution

Simple ciphers are declared useless by cryptography. Therefore, many of them have been improved. The Gronsfeld cipher is a modification of the Caesar cipher. This method is much more resistant to hacking and lies in the fact that each character of the encoded information is encrypted using one of the different alphabets, which are repeated cyclically. It can be said that this is a multi-dimensional applicationthe simplest substitution cipher. In fact, the Gronsfeld cipher is very similar to the Vigenère cipher discussed below.

ADFGX encryption algorithm

This is the most famous World War I cipher used by the Germans. The cipher got its name because the encryption algorithm led all ciphergrams to the alternation of these letters. The choice of the letters themselves was determined by their convenience when transmitted over telegraph lines. Each letter in the cipher is represented by two. Let's look at a more interesting version of the ADFGX square that includes numbers and is called ADFGVX.

A D F G V X
A J Q A 5 H D
D 2 E R V 9 Z
F 8 Y I N K V
G U P B F 6 O
V 4 G X S 3 T
X W L Q 7 C 0

The ADFGX squaring algorithm is as follows:

  1. Pick random n letters for columns and rows.
  2. Building an N x N matrix.
  3. Enter the alphabet, numbers, characters randomly scattered over the cells into the matrix.

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

A B B G D
A E/E N b/b A I/Y
B W V/F G/R З D
B Sh/Sh B L X I
G R M O Yu P
D F T T S U

This matrix looks strange because a row of cells contains two letters. This is acceptable, the meaning of the message is not lost. It can be easily restored. Let's encrypt the phrase "Compact cipher" using this table:

1 2 3 4 5 6 7 8 9 10 11 12 13 14
Phrase K O M P A K T N S Y Ш & F R
Cipher bw gv gb where ag bw db ab dg hell wa hell bb ha

Thus, the final encrypted message looks like this: "bvgvgbgdagbvdbabdgvdvaadbbga". Of course, the Germans carried out a similar line through several more ciphers. And in the end it turned out very stableto crack the encrypted message.

Vigenère cipher

This cipher is an order of magnitude more resistant to cracking than monoalphabetic ones, although it is a simple text replacement cipher. However, due to the robust algorithm, it was long considered impossible to hack. The first mention of it dates back to the 16th century. Vigenère (a French diplomat) is erroneously credited as its inventor. To better understand what is at stake, consider the Vigenère table (Vigenère square, tabula recta) for the Russian language.

Vigenère table with Russian alphabet
Vigenère table with Russian alphabet

Let's start coding the phrase "Kasperovich laughs". But for encryption to succeed, a keyword is needed - let it be "password". Now let's start encryption. To do this, we write the key so many times that the number of letters from it corresponds to the number of letters in the encrypted phrase, by repeating the key or cutting:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
Phrase: K A С P E R O B & W С M E E T С I
Key P A R O L b P A R O L b P A R O L

Now, using the Vigenère table, as in 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=C, etc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
Cipher: b B B Yu С N Yu G Sch F E Y X F G A L

We get that "Kasperovich laughs"="bvusnyugschzh eykhzhgal".

Cracking the Vigenère cipher is so difficult because frequency analysis needs to know the length of the keyword to work. So the hack is to throw the length of the keyword at random and try to crack the secret message.

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

Codes

Real codes consist of matches for eachwords 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
ASCII code table

The main advantage of codes is that they are very difficult to decipher. Frequency analysis almost does not work when they are hacked. 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 desired object and the interception of even part of the book forces you to change all the codes completely.

In the 20th century, many states used codes to transfer secret data, changing the code book after a certain period. And they also actively hunted for books of neighbors and opponents.

Enigma

Everyone knows that Enigma was the Nazis' main cipher machine during World War II. Enigma's 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 one message in several ways throughout its entire length.

In contrast to the simplest ciphers, "Enigma" gave trillions of possible combinations, which made cracking encrypted information almost impossible. In turn, the Nazis had a certain combination prepared for each day, which theyused on a particular day to send messages. Therefore, even if Enigma fell into the hands of the enemy, it did nothing to decrypt messages without entering the correct configuration every day.

Nazi Enigma cipher machine
Nazi Enigma cipher machine

Hack "Enigma" was actively tried during the entire military campaign of Hitler. 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 operation of several dozen Enigmas simultaneously and run intercepted Nazi messages through them. But even the Turing machine was only occasionally able to crack the message.

Public key encryption

The most popular of the encryption algorithms, which is used everywhere in technology and computer systems. Its essence lies, 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 private key is used to decrypt it.

Public key encryption algorithm
Public key encryption algorithm

The public key is most often a very large number that has only two divisors, not counting one and the number itself. Together, these two divisors form a secret key.

Let's 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 5181. Are you saying too easy? What if in the rolepublic number will be a number with 60 digits? Mathematically difficult to calculate the divisors of a large number.

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

Font durability

The cryptographic strength of an encryption algorithm is the ability to resist hacking. This parameter is the most important for any encryption. Obviously, the simple substitution cipher, which can be decrypted by any electronic device, is one of the most unstable.

Today, there are no uniform standards by which it would be possible to assess the strength of the cipher. This is a laborious and long process. However, there are a number of commissions that have produced standards in this area. For example, the minimum requirements for the Advanced Encryption Standard or AES encryption algorithm developed by NIST USA.

For reference: the Vernam cipher is recognized as the most resistant cipher to breaking. At the same time, its advantage is that, according to its algorithm, it is the simplest cipher.

Recommended: