Cryptography: spy games. Replacement ciphers

Since there are a huge number of ciphers in the world, it is impossible to consider all the ciphers not only within the framework of this article, but also the entire website. Therefore, we will consider the most primitive encryption systems, their application, as well as decryption algorithms. The goal of my article is to explain to a wide range of users the principles of encryption/decryption in the most accessible way possible, as well as to teach primitive ciphers.

Back at school, I used a primitive cipher, which my older comrades told me about. Let's consider the primitive cipher “Cipher with letters replaced by numbers and vice versa.”

Let's draw a table, which is shown in Figure 1. We arrange the numbers in order, starting with one and ending with zero horizontally. Below the numbers we substitute arbitrary letters or symbols.

Rice. 1 Key to the cipher with replacement of letters and vice versa.

Now let's turn to table 2, where the alphabet is numbered.

Rice. 2 Table of correspondence between letters and numbers of alphabets.

Now let's encrypt the word C O S T E R:

1) 1. Let's convert letters into numbers: K = 12, O = 16, C = 19, T = 20, E = 7, P = 18

2) 2. Let’s convert the numbers into symbols according to Table 1.

KP KT KD PSH KL

3) 3. Done.

This example shows a primitive cipher. Let's look at fonts that are similar in complexity.

1. 1. The simplest cipher is the CIPHER WITH REPLACEMENT OF LETTERS BY NUMBERS. Each letter corresponds to a number in alphabetical order. A-1, B-2, C-3, etc.
For example, the word “TOWN” can be written as “20 15 23 14”, but this will not cause any particular secrecy or difficulty in deciphering.

2. You can also encrypt messages using a NUMERIC TABLE. Its parameters can be anything, the main thing is that the recipient and sender are aware. Example of a digital table.

Rice. 3 Digital table. The first digit in the cipher is a column, the second is a row, or vice versa. So the word “MIND” can be encrypted as “33 24 34 14”.

3. 3. BOOK CIPHER
In such a cipher, the key is a certain book that is available to both the sender and the recipient. The cipher indicates the page of the book and the line, the first word of which is the solution. Decryption is impossible if the sender and the correspondent have books of different years of publication and issue. The books must be identical.

4. 4. CAESAR CIPHER(shift cipher, Caesar shift)
Well-known cipher. The essence of this cipher is the replacement of one letter with another, located at a certain constant number of positions to the left or right of it in the alphabet. Gaius Julius Caesar used this encryption method when corresponding with his generals to protect military communications. This cipher is quite easy to crack, so it is rarely used. Shift by 4. A = E, B= F, C=G, D=H, etc.
An example of a Caesar cipher: let's encrypt the word “DEDUCTION”.
We get: GHGXFWLRQ. (shift by 3)

Another example:

Encryption using key K=3. The letter "C" "shifts" three letters forward and becomes the letter "F". A hard character moved three letters forward becomes the letter “E”, and so on:

Original alphabet: A B C D E F G H H I J J K L M N O P R S T U V X C

Encrypted: G D E E F G H I J K L M N O P R S T U V

Original text:

Eat some more of these soft French rolls and drink some tea.

Ciphertext is obtained by replacing each letter of the original text with the corresponding letter of the cipher alphabet:

Fezyya yz zyi ahlsh pvenlsh chugrschtskfnlsh dsosn, zhg eyutzm ygb.

5. CIPHER WITH CODE WORD
Another simple method in both encryption and decryption. A code word is used (any word without repeating letters). This word is inserted in front of the alphabet and the remaining letters are added in order, excluding those that are already in the code word. Example: code word – NOTEPAD.
Original: 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
Replacement: N O T E P A D B C F G H I J K L M Q R S U V W X Y Z

6. 6. ATBASH CIPHER
One of the simplest encryption methods. The first letter of the alphabet is replaced by the last, the second by the penultimate, etc.
Example: "SCIENCE" = HXRVMXV

7. 7. FRANCIS BACON CIPHER
One of the simplest encryption methods. Encryption uses the Bacon cipher alphabet: each letter of a word is replaced by a group of five letters "A" or "B" (binary code).

a AAAAAA g AABBA m ABABB s BAAAB y BABBA

b AAAAB h AABBB n ABBAA t BAABA z BABBB

c AAABA i ABAAA o ABBAB u BAABB

d AAABB j BBBAA p ABBBA v BBBAB

e AABAA k ABAAB q ABBBB w BABAA

f AABAB l ABABA r BAAAA x BABAB

The difficulty in decrypting lies in determining the cipher. Once it is determined, the message is easily alphabetized.
There are several coding methods.
It is also possible to encrypt the sentence using binary code. The parameters are determined (for example, “A” - from A to L, “B” - from L to Z). So BAABAAAAABAAAABABABB stands for TheScience of Deduction! This method is more complicated and tedious, but much more reliable than the alphabetical option.

8. 8. BLAISE VIGENERE CIPHER.
This cipher was used by the Confederates during the Civil War. The cipher consists of 26 Caesar ciphers with different shift values ​​(26 letters of the Latin alphabet). A tabula recta (Vigenère square) can be used for encryption. Initially, the key word and the source text are selected. The word key is written cyclically until it fills the entire length of the source text. Further along the table, the letters of the key and the original text intersect in the table and form the ciphertext.

Rice. 4 Blaise Vigenere Cipher

9. 9. LESTER HILL CIPHER
Based on linear algebra. It was invented in 1929.
In such a cipher, each letter corresponds to a number (A = 0, B = 1, etc.). A block of n-letters is treated as an n-dimensional vector and multiplied by an (n x n) matrix mod 26. The matrix is ​​the cipher key. To be decryptable, it must be reversible in Z26n.
In order to decrypt a message, you need to turn the ciphertext back into a vector and multiply by the inverse key matrix. For detailed information, Wikipedia can help.

10. 10. TRITEMIUS CIPHER
Improved Caesar cipher. When decoding it is easiest to use the formula:
L= (m+k) modN , L-number of the encrypted letter in the alphabet, m-ordinal number of the letter of the encrypted text in the alphabet, k-shift number, N-number of letters in the alphabet.
It is a special case of an affine cipher.

11. 11. MASONIC CIPHER



12. 12. GRONSFELD CIPHER

In terms of its content, this cipher includes the Caesar cipher and the Vigenère cipher, but the Gronsfeld cipher uses a numerical key. Let's encrypt the word “THALAMUS” using the number 4123 as a key. We enter the numbers of the numerical key in order under each letter of the word. The number under the letter will indicate the number of positions by which the letters need to be shifted. For example, instead of T you get X, etc.

T H A L A M U S
4 1 2 3 4 1 2 3

T U V W X Y Z
0 1 2 3 4

As a result: THALAMUS = XICOENWV

13. 13. PIG LATIN
More often used as children's fun, it does not cause any particular difficulty in deciphering. The use of English is mandatory, Latin has nothing to do with it.
In words that begin with consonants, those consonants are moved back and the “suffix” ay is added. Example: question = questionquay. If the word begins with a vowel, then ay, way, yay or hay is simply added to the end (example: a dog = aay ogday).
In Russian, this method is also used. They call it differently: “blue tongue”, “salty tongue”, “white tongue”, “purple tongue”. Thus, in the Blue language, after a syllable containing a vowel, a syllable with the same vowel is added, but with the addition of a consonant “s” (since the language is blue). Example: Information enters the nuclei of the thalamus = Insiforsomasatsiyasya possotussupasaetse v yadsyarasa tasalasamususasa.
Quite an exciting option.

14. 14. POLYBIUS SQUARE
Similar to a digital table. There are several methods for using the Polybius square. An example of a Polybius square: we make a 5x5 table (6x6 depending on the number of letters in the alphabet).

1 METHOD. Instead of each letter in a word, the corresponding letter below is used (A = F, B = G, etc.). Example: CIPHER - HOUNIW.
2 METHOD. The numbers corresponding to each letter from the table are indicated. The first number is written horizontally, the second – vertically. (A = 11, B = 21...). Example: CIPHER = 31 42 53 32 51 24
3 METHOD. Based on the previous method, we will write the resulting code together. 314253325124. Shift left one position. 142533251243. Again we divide the code in pairs. 14 25 33 25 12 43. As a result, we get the cipher. The pairs of numbers correspond to the letter in the table: QWNWFO.

There are a great variety of ciphers, and you can also come up with your own cipher, but it is very difficult to invent a strong cipher, since the science of decryption has stepped far forward with the advent of computers and any amateur cipher will be cracked by specialists in a very short time.

Methods for opening mono-alphabetic systems (decoding)

Despite their simplicity in implementation, mono-alphabetic encryption systems are easily vulnerable.
Let us determine the number of different systems in an affine system. Each key is completely defined by a pair of integers a and b, specifying the mapping ax+b. There are j(n) possible values ​​for a, where j(n) is the Euler function returning the number of coprime numbers with n, and n values ​​for b that can be used regardless of a, except for identity mapping (a=1 b =0), which we will not consider.
This gives j(n)*n-1 possible values, which is not that many: with n=33 a can have 20 values ​​(1, 2, 4, 5, 7, 8, 10, 13, 14 , 16, 17, 19, 20, 23, 25, 26, 28, 29, 31, 32), then the total number of keys is 20*33-1=659. Searching through such a number of keys will not be difficult when using a computer.
But there are methods that simplify this search and that can be used when analyzing more complex ciphers.
Frequency analysis
One such method is frequency analysis. The distribution of letters in the cryptotext is compared with the distribution of letters in the alphabet of the original message. The letters with the highest frequency in the cryptotext are replaced by the letter with the highest frequency from the alphabet. The probability of a successful attack increases with increasing cryptotext length.
There are many different tables about the distribution of letters in a given language, but none of them contains definitive information - even the order of letters may differ in different tables. The distribution of letters depends very much on the type of test: prose, spoken language, technical language, etc. The laboratory work instructions provide frequency characteristics for various languages, from which it is clear that the letters I, N, S, E, A (I, N, S, E, A) appear in the high-frequency class of each language.
The simplest defense against frequency-counting attacks is provided by the system of homophones (HOMOPHONES) - monophonic substitution ciphers in which one plaintext character is mapped onto several ciphertext characters, their number proportional to the frequency of occurrence of the letter. When encrypting the letter of the original message, we randomly select one of its replacements. Therefore, simply counting frequencies does not give the cryptanalyst anything. However, information is available on the distribution of pairs and triplets of letters in various natural languages.

When encrypting using the substitution method, the letters of the source text can be replaced with geometric shapes, figures of people, animals, any drawings, symbols, letters or numbers (groups).

EACH LETTER IS CODED ONLYIN ONE NUMBER

IN Appendix No. 30 shows a simple substitution method where 33 numbers are used to encode 33 letters. Each of the 33 letters is replaced by one of the numbers: 01, 02, 03, ...,33.

Option 1

This table is used to encode the code from a children's coloring book. Modern alphabetical positional numbering is similar to the numerical correspondence of letters in the Slavic alphabet. This is a simple table. Here the numbers used for encoding are arranged in order.

Option 2

Here the numbers (two-digit digital groups) are drawn in a lottery order using the principle of random numbers.

In case of theft or loss (compromise) of the table, you can complicate it - agree to rearrange the numbers in each group. For example, A = 05 - write 50 in encryption.

EVERY LETTER IS CODEDIN TWO GROUPS

The total number of numbers (digital groups) used for coding is 2 times more than letters.

In table No. 1 ( Appendix No. 31) - 49 letters, numbers and symbols + reserve, for encoding which 100 numbers (groups) are used. The first and second lines are two-digit groups used for encoding. Groups “36” and 63” - reserve. The third, bottom line - letters, numbers and punctuation marks. To encode each letter, first one or the other group (standing above the letter) is used, alternating. In this table, the groups are arranged in numerical order. These types of tables are not difficult to store in memory.

In table No. 2 ( application No. 32) groups used for coding are located chaotically. Table No. 2 consists of two tables. The left table is for coding (code table). The right one is for decoding (decipherer). Opposite each letter (in the left table) there are two two-digit groups that are used to replace a given letter, alternating alternately. For example, the word “hut” will look like this: 15 68 06 12 82. To mislead the enemy, this ciphergram can be written like this: 156 806 128 224 or like this: 1568 0612 8276. To complete the last group, we use a reserve.

USE TO REPLACE EACHLETTERS OF SEVERAL GROUPS

During the encryption process, 3, 4 or more groups can be used to replace each letter . Accordingly, the total number of groups used for encryption can be 3, 4 and n times more than the letters in the alphabet.

ADVANCED CODING.

Unlike Appendix No. 30, all numbers used here to encode letters are taken from the multiplication table. The word "SHALASH" encoded according to the code table presented in Appendix No. 33, will look like this: 10 24 40 24 10.


To complicate it using the multiplication table, we replace the letter code with factors: instead of “10” we write “25” or “52” (2´5 = 5´2 = 10), “24” we replace with “38”, “83”, “ 46" or "64" (3´8 = 8´3 = 4´6 = 6´4 = 24), etc. After complication, the encryption will look like this: 25 38 85 46 52. Thus, for encoding each letter there will be not one number is used, but several (2-4), which will make the cipher more reliable, since the same numbers (groups) will be repeated less frequently in the encrypted text.

Even if you lose such a table, or it is stolen, spied on, or copied, attackers will not be able to use it (decrypt it) because in the cryptogram there will be no digital groups from the code table, but there will be groups consisting of factors.

In order not to attract the attention of strangers, the ciphergram can be disguised as the arithmetic operations of a first-grader and written like this:

Classwork

2´5 = 10, 3´8 = 24, 8´5 = 40, 4´6 = 24, 5´2 = I0

The message can be conveyed in short parts.

Similar to the above, you can use “Four-digit mathematical tables” by V.M. Bradis - exact products of two-digit numbers. A four-digit number is decomposed into 2 two-digit factors.

A DIFFERENT NUMBER OF GROUPS IS USED TO REPLACE EACH LETTER

Let's consider an encryption system in the form of a table of size 10‰10 (sizes may be different). Let's number the rows and columns. We denote the tenth row and column as zero (numbering can begin not from 1, but from 0). Numbering can be alphabetic. Moreover, not the same, but different letters can be used to number rows and columns. Each cell has coordinates consisting of two numbers or letters - a row number and a column number. Let's fill the cells of the table with the letters of the alphabet, the necessary punctuation marks, and numbers. In this case, we will distribute 100 cells proportionally, depending on the frequency of use of letters in the Russian language. Let's leave a few cells empty. If necessary, we will use blanks instead of spaces to indicate the red line, to complete the last groups (in case of regrouping) and as a reserve.

In the simplest version, the letters are entered into the table in alphabetical order, and the numbers are in ascending sequence (this arrangement of symbols is not difficult to remember). Moreover, frequently occurring letters are repeated the required number of times: so the letter O will occupy 8-9 cells, the letter E will occupy 7-8 cells, the letter A will be repeated 6-7 times, the letter I will be written 5-6 times, etc. Rows and columns can be numbered in reverse or random order.

In the complicated version, first some memorized text (for example, a poem) is written in, then the letters of the alphabet that are not included in this text are added. First, any memorable numbers are entered (for example, 1945 - the year of the end of the Second World War), then the rest. Thus, the arrangement of characters in the table will be conditionally random, which increases the strength of the cipher. Different rules apply for filling out the table in an easy-to-remember order. In our example, in the table ( application No. 34) the memorized phrase is written down at the beginning, followed by the memorized numbers, then the remaining letters of the alphabet, followed by punctuation marks and the remaining numbers, and finally, the required number of frequently occurring letters are added. The numbering of rows and columns has two options (numeric and alphabetic).

During the encryption process, the letter of the original text is found in the table and replaced with a two-digit numeric group (coordinates), in which one digit is the row number and the other is the column number.

Let's encrypt the text (BIG PROFIT IS BETTER THAN SMALL DISADVANTAGE.) and get a cryptogram (17 45 49 40 10 37 13 88 18 40 24 43 39 95 15 12 29 23 96 11 57 49 21 44 89 68 17 77 19 18 87 16 43 80 78 76 97 05 25 69 08 98 11 50). In the resulting cryptogram, despite the short plaintext, repeating (identical) two-digit groups are visible. If the encryption is regrouped into groups of 3, 4 or 5 characters, repetitions of identical two-character groups will be invisible.

If we apply alphabetic numbering of rows and columns, the ciphergram will have a different form: LZH OD OI OK LK NZH LV TZ LZ OK MG OV NI UD LD LB MI MV UE LA PZH OI MA OGTI RZ LV SZH LI LZ TZH LE OV TK SZ SE UZH FD MD RI FZ UZ LA PC. To make it more complicated, you can write the symbols in every second group of the ciphergram in reverse order - first the column number, and then the row number. Or combine - alternate digital and letter groups.

The table in question is different from the column-by-column replacement table shown in Appendix No. 32, in that, in addition to the random correspondence between a symbol and a two-digit group, we have an unequal (approximately proportional to the frequency of use) number of replacement groups for different letters, which reduces the manifestation of patterns and characteristics of the source text in the ciphergram.

CIPHERPADPAPER MANUFACTURING CIPHERPADPAPER

Take an ordinary notebook (notebook) with the alphabet. Add the missing letters to it: E, J, Ъ, И, ь. It is also advisable to add punctuation marks after the letters: period, comma, question mark. In total there are 36 letters and symbols in the notebook. If necessary, you can enter numbers and other characters.

For encryption, use 1000 groups, each with three digits (three-digit numbers): 000, 001, 002, 003 and so on up to 999.

For simplicity, distribute the three-digit groups equally. 1000: 36 = 27 and 28 in remainder. Use 27 groups to encrypt each letter and punctuation mark. Leave the remaining 28 in reserve. Please select a separate page for your reservation.

When compiling a notebook, three-digit groups are drawn in a lottery order based on the principle of random numbers. To do this, cut out small rectangular pieces from cardboard - 1000 pieces. Write a number on each: 000, 001, 002, 003, etc. up to 999. Place them in a box and mix. Open your notepad to the page with the letter “A”. Take any number from the box, for example, 323. Write this number in a notepad on the page with the letter “A”. Place this number in another, empty box. Take the second number from the box, for example, 162. Write this number in a notebook, and put the number in another box.

Take out the next, third, number from the box. Write down the next number in a notepad, for example, 952. Etc. until there are 27 groups written on the page with the letter “A”.

323 162 952 338 566 532 959 379 005 837 832 582 035 818 460 615 907 464 814 931 564 690 305 405

336 259 179 286 177 059 236 790 971 113 504 390 910 331 458 422 856 496 025 370 217 232 794 598 724 345 486

Similarly, type and enter numbers (three-digit digital groups) for other letters and punctuation marks. Record the remaining 28 groups as reserves.

To decrypt on free sheets of paper, make a special table at the beginning of your notebook - DECORDING. The decryptor consists of two columns. The first column is numbers in order, three-digit groups: 000, 001, 002, 003, etc. up to 999. Second column - letters and signs. First, write down the first column in your notebook - serial numbers. Then fill in the second column - opposite each serial number the corresponding letter or sign.

To do this, open your notepad to the page with the letter “A”. The first group here is 323. Against serial number 323 of the decipherer, write the letter “A”. The second group is 162. Against the serial number 162 in the decipherer write the letter “A”, etc.

Next, open the notebook on the page with the letter “B” and in the decipherer, write down the letter “B” against the corresponding groups (ordinal numbers). Similarly, fill in the second column of the decipherment with the remaining letters and punctuation marks. Against groups that are in the reserve - empty (for example, No. 260).

The cipher pad and the decipherer for it are shown in Appendix No. 35.

TEXT ENCRYPTION

For example, you need to encrypt the word “BABA”. The first letter in the text is “B”. Open your notepad to the page with the letter “B”. The first group is 336. Write it under (above) the first letter “B” in the text. See the text further to see if there are any more letters “B” in the text. Encrypt the second letter “B” with the second group - 259, etc. Encrypt each letter in a new group until all the letters “B” in the text are encrypted. This technique eliminates the reuse of groups.

We return to the beginning of the original text. The second letter in the text is “A”. Open your notepad to the page with the letter "A". The first group here is 323. Write it under the letter “A”. Encrypt the next letter “A” with the second group - 162. And so on, until all the letters “A” in the text are encrypted.

Encrypt the remaining letters of the text in the same way (there are none in the example above). The result is a ciphergram: 336 323 259 162. To replace each letter, you can use any of the 27 groups intended for a given letter, in any order, preventing reuse of the same group.

DECRYPTION

To decrypt the cryptogram, find serial number 336 in the decipherer. Opposite it is the letter

- “B”. Write the letter “B” under the first group of the code. The second group in the ciphergram is 323. Find serial number 323 in the decipherment. Opposite it is the letter “A”. Write it down under the second group of the ciphergram. Etc.

It will work out:

OPERATING RULES

Work with confidential information and SRS-DRC should be carried out in the absence of strangers. When encrypting, reuse of the same group is prohibited. If the text is large and the notepad does not allow you to encrypt the entire text without reusing groups, break it into parts and transmit it in parts as separate ciphergrams.

Destroy damaged sheets and drafts, as well as ciphergrams and secret texts that have lost their meaning.

If you need to add other characters or numbers to the notebook, use part of the reserve. The numbers can be placed separately after the letters at the end of the notebook or together with the letters in alphabetical order: 1 - one - after the letter “O”, 2 - two - after the letter “D”, etc. Reserve groups can be used as a section sign (to indicate a space or a red line), to complete the last groups when regrouping the ciphergram, and in other cases.

Of course, when making a cipher pad, you need to distribute replacement elements (cipher designations) for each letter not equally, but in an amount proportional to the frequency of use of letters in the Russian language. But the uniform distribution of three-digit digital groups, shown in the example of this cipherpad, makes it possible to more conveniently and efficiently change the key. Allows you to apply a shift by one or more positions. The alphabet of the cipherpad is numbered. Numbering starts from zero, i.e. the letter “A” is assigned the serial number 0, the letter “B” is assigned the serial number 1, the letter “B” is assigned 2, etc. This numbering helps to navigate well and calculate the groups needed for replacement.

So, for example, when shifting by three positions (the key is 3), to replace the letter “A”, groups intended for the letter “G” are used - to the serial number of the letter “A” (0) we add the value of the key (3) and we get the serial number letters "G" (3). During the encryption process, the letter of the source text “B” is replaced by three-digit digital groups intended for the letter “D” - the serial number of the letter “B” (1) is added to the value of the key (3) and we obtain the serial number of the paragraph corresponding to the letter “D” ( 4), etc.

You can divide the alphabet in pairs and use groups intended for the letter “B” to replace the letter “A”. To replace the letter “B”, use groups intended for the letter “A”, and so on.

Change the key according to a special secret schedule (key change schedule).

1. The simplest system of this cipher is that the alphabet is divided into groups with an equal number of letters and each of them is designated by two numbers. The first digit indicates the group, and the second - the serial number of the letter in this group.

ABVG DEZHZ IKLM NOPR STUF KhTSCHSH SHCHYYUYA
1 2 3 4 5 6 7

Encrypted words, for example "Criminal Investigation", will look like this:

53 14 42 33 42 13 41 72 31 44 42 24 72 51 32

The alphabet can be taken not in the usual order, but with any permutation of letters.

2. The cipher can be complicated according to the following scheme:

Letters are made up of two numbers. The first is her place in the group, and the second indicates the group number. For example, the word “danger” in encrypted form will look like this:

33 37 14 32 34 33 32 35 58

To make it more difficult to read, the word can be written in one line:

333714323433323558

3. This also includes digital writing, where the letters are divided into five groups, each of which is provided with two numbers.


groups

places

Each letter is represented as a fraction in such a way that its numerator is the group number, and its denominator is the number of the place in the group. Since this scheme does not use numbers above six, numbers from seven to nine can be used as empty signs.
With this cipher the word “day” can be written as follows:

71 81 30 57
95 76 19 38

4. Multiplying cipher. To work with it, you need to remember the code number and agree in advance whether all the letters of the alphabet will be used and whether any will be thrown out.

Let's assume that the code number is 257, and the letters are excluded from the alphabet: й, ь, ъ, ы, i.e. it looks like this:

ABVGDEYZHZIKLMNOPRSTUFCHTSCHSHSHSHYYA

You need to encrypt the expression:
"Meeting tomorrow."
The text is written out of order for ease of encryption:

V S T R E H A Z A V T R A
2 5 7 2 5 7 2 5 7 2 5 7 2

A number is written under each letter until the phrase ends. Then, instead of each letter of the text, the letter of the alphabet is written which appears first after the number of letters indicated by the number at the bottom, and the counting is done to the right. So, under the first letter “B” there is the number “2”, so instead of the letter “B” in the encryption letter the third letter of the alphabet “D” is placed. Under the second letter of the text “C” there is the number “5”, so the sixth letter after “C” is placed instead of it, i.e. letter "C".
In digital form, the letter will take the following form:

DTSSHTKBV NZHDCHV

To read the encryption, you need to put a key code number under each letter. In our case, the number is 257. And in the alphabet, count to the left of a given letter of a cipher letter as many letters as the number in front of it indicates.
This means that instead of the letter “D” the second letter to the left will be the letter “B”, and instead of the “C” there will be the fifth letter, which means the letter “C”.

D C SCH T K B V N F D H H H
2 5 7 2 5 7 2 5 7 2 5 7 2
V S T R E H A Z A V T R A

Based on materials from L.A. Milyanenkov
On the other side of the law
encyclopedia of the underworld

The need to encrypt correspondence arose in the ancient world, and simple replacement 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 every 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 decipher dead languages ​​such as ancient Egyptian or Latin.

Steganography

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

Steganography is the simplest cipher. Typical examples are swallowed notes covered with wax, or a message on a shaved head that is hidden under the growth of 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 discreetly marked.

The main disadvantage of steganography is that an attentive outsider can notice it. Therefore, to prevent the secret message from being easily read, encryption and encoding 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 is that each letter is encrypted by shifting the alphabet 1 letter forward. A -> B, B -> B, ..., I -> A. For example, let’s encrypt the phrase “our Nastya is crying loudly” and get “obshb 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 offset. In this form, the cipher has been known since ancient times and is called the “Caesar cipher.”

The Caesar cipher is very simple and fast, but it is a simple single permutation cipher and is therefore easy to break. Having a similar drawback, it is only suitable for children's pranks.

Transposition or permutation ciphers

These types of simple permutation ciphers are more serious and have been actively used not so long ago. During the American Civil War and World War I it was used to transmit messages. Its algorithm consists of rearranging the letters - 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 - ezhot 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 can be easily cracked by simple brute force or dictionary matching, today any smartphone can decipher it. Therefore, with the advent of computers, this cipher also became a children's code.

Morse code

The alphabet 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 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 transmitting a message using the telegraph, dashes and dots represent long and short signals.

The telegraph and alphabet was the one who was the first to patent “his” invention in 1840, although similar devices had been invented before him in both Russia and England. But who cares now... The telegraph and Morse code had a very great influence on the world, allowing almost instantaneous transmission of messages over continental distances.

Monoalphabetic substitution

ROTN and Morse code described above are representatives 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 a single encryption alphabet.

Deciphering simple substitution ciphers is not difficult, and this is their main drawback. They can be solved by simply searching or For example, it is known that the most used letters in the Russian language are “o”, “a”, “i”. Thus, we can assume that in the ciphertext, the letters that appear most often mean either “o”, “a”, or “i”. Based on these considerations, the message can be deciphered even without computer search.

Mary I, Queen of Scots from 1561 to 1567, is known to have used a very complex monoalphabetic substitution cipher with multiple 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 considered useless by cryptography. Therefore, many of them have been modified. The Gronsfeld cipher is a modification of the Caesar 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 repeated cyclically. We can say that this is a multidimensional application of the 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 it reduced all ciphergrams to alternating 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 algorithm for composing the ADFGX square is as follows:

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

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

A B IN G D
A HER N b/b A I/Y
B H V/F H/C Z D
IN Sh/Shch B L X I
G R M ABOUT YU P
D AND T C Y U

This matrix looks strange, since a number of cells contain 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 TO ABOUT M P A TO T N Y Y Sh AND F R
Cipher bv guards GB gd ah bv db ab dg hell va hell bb ha

Thus, the final encrypted message looks like this: “bvgvgbgdagbvdbabdgvdvaadbbga.” Of course, the Germans ran a similar line through several more ciphers. And the result was a very hack-resistant 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, thanks to its robust algorithm, it was considered impossible to hack for a long time. Its first mentions date back to the 16th century. Vigenère (a French diplomat) is mistakenly considered its inventor. To better understand what we are talking about, consider the Vigenère table (Vigenère square, tabula recta) for the Russian language.

Let's start encrypting the phrase “Kasperovich laughs.” But for encryption to succeed, you need a keyword - let it be “password”. Now let's start encryption. To do this, we write down 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 it off:

Now, using the coordinate plane, we look for a cell that is the intersection of pairs of letters, and we get: K + P = b, A + A = B, C + P = B, etc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
Cipher: Kommersant B IN YU WITH N YU G SCH AND E Y X AND G A L

We get that “Kasperovich laughs” = “abvyusnyugshch eykhzhgal.”

It's so difficult to hack because frequency analysis requires knowing the length of the keyword for it to work. Therefore, hacking involves randomly throwing in the length of a keyword and trying 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 the Russian alphabet written line by line with an offset of one. Which brings 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 may be a key, without knowing which it will be impossible to read the message, even knowing the key.

Codes

Real codes consist of correspondences for each word of a separate code. To work with them, you need so-called code books. 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 - the international cipher of simple characters.

The main advantage of codes is that they are very difficult to decipher. Frequency analysis almost doesn't work when hacking them. The weakness of the codes is, in fact, the books themselves. Firstly, their preparation is a complex and expensive process. Secondly, for enemies they turn into a desired object, and intercepting even part of the book forces them to change all the codes completely.

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

"Enigma"

Everyone knows that Enigma was the main Nazi encryption machine during World War II. The Enigma structure includes a combination of electrical and mechanical circuits. How the cipher turns out depends on the initial configuration of the 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 breaking encrypted information almost impossible. In turn, the Nazis had a specific combination prepared for each day, which they used on a specific day to transmit messages. Therefore, even if Enigma fell into the hands of the enemy, it did not contribute in any way to deciphering messages without entering the necessary configuration every day.

They actively tried to break Enigma throughout Hitler's military campaign. In England in 1936, one of the first computing devices (Turing machine) was built for this purpose, 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 a message.

Public key encryption

The most popular encryption algorithm, 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 secret key is used to decrypt it.

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

Let's look at 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. Would you say it's too simple? What if the public number is a number with 60 digits? It is mathematically difficult to calculate the divisors of a large number.

For a more realistic example, imagine that you are withdrawing money from an ATM. When a card is read, 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. But there are no ways to quickly find key dividers when intercepting it.

Font durability

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

To date, there are no uniform standards by which the strength of a cipher can be assessed. This is a labor-intensive 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 crack. At the same time, its advantage is that, according to its algorithm, it is the simplest cipher.

1. The simplest form of such a cipher: the letters are simply rearranged. For example, instead of the letter “A” the letter “C” is placed, instead of the letter “B” - “I” and so on. The cipher is very easy to use, and it is usually complicated. For example, words are written without any gaps, and if gaps are made, then “empty” characters and words are inserted in the wrong places. Sometimes several alphabets are used for one encryption. For example, the first line is written in one alphabet, and the second (even) in another, as a result of which reading becomes much more difficult.
2. A cipher of vowels, one of the keys of which is given below.

. A E AND ABOUT U E
YU A B IN G D E
U AND Z AND Y TO L
Y M N ABOUT P R WITH
A T U F X C H
AND Sh SCH Kommersant Y b E
I YU I Z S W t

The order of vowels in the table can be changed arbitrarily. Each letter is replaced according to this key by two vowels: the first is the vowel to the left, and the next one is the one located farthest up from the desired letter. For example, the letters “P” in encrypted form will look like this - “YU”, the letters “A” - “YUA”, the word “money” - “YU YUE YIU YO YU”. The writing appears to be nonsense, but it can be made even more confusing by introducing consonants as “blank” letters and then creating words with random spaces between syllables. For example, write the same word “money” as follows: YUURZHYU ZKLBYE IU YO VGCHUI.” It is unlikely that anyone will be able to read such encryption.

3. The multiplying cipher will be more advanced. It is very easy to use and difficult to decipher. It is convenient because it does not require storing a encryption table with you - it can be easily compiled from memory. See table.

To work with this cipher, in addition to the table, you also need to know the code word-key. Suppose that such a key is the word “Leningrad” and you need to give a notice with the following content: “Beware of Smirnov.”
We break this sentence into separate letters and under each we put a letter from the key word. If there are not enough letters of the keyword for the entire phrase, we begin to write it again, interrupting at the last letter of the message (in our example, the letter “C”).

B E R E G I S M I R N O V A
L E N I N G R A D L E N I N G R

After this, the first letter of the transmitted message (we have the letter “B”) is found in the first HORIZONTAL line of the table and the first letter of the key word - “L” - in the first VERTICAL line of the table. From the first letter (the letter “B”) we mentally draw a line down, and from the second letter (the letter “L”) - to the right until the lines intersect in the cell with the letter “H”. We do the same with all other letters of the text. At first it seems difficult, but speed is acquired with work.
In encrypted form, our message will look like this:

NLYUORMBE TSSHUETSZHS

Decoding is done as follows. First, a keyword is written under the text, and its first letter “L” is found in the first VERTICAL column, and to the right of it the first letter of the message is found, which means the letter “N”. Mentally rising up from this letter, we find the letter “B” in the first HORIZONTAL line - this is the actual letter of the ciphertext. We do the same with each subsequent letter.

NLYUORMBE TSSHUETSZHS
LEN INGRA D LE NING R

Based on materials from L.A. Milyanenkov
On the other side of the law
encyclopedia of the underworld