Encryption methods. The simplest methods for encrypting text

Subscribe
Join the “koon.ru” community!
In contact with:

The most primitive cipher is the use of auxiliary words or letters. As children, many people tried to speak in a made-up language, for example, adding the syllable “ma” after each vowel. This method only works during a conversation; others are unlikely to understand you. It is unlikely that it will be possible to encrypt written information in this way, since such an algorithm is easy to calculate.

Another children's cipher is the removal of any letters from a word. Most often, all vowels or every second letter are eliminated. So, for example, from the sentence “Come to visit” you can get “prkhd in gst”. Deciphering without additional information is not difficult.

Symmetric ciphers

In another way they are called symmetric cryptosystems. The peculiarity of this encryption method is that the same key is used for encryption and decryption. The algorithm must be agreed upon by the parties in advance.

One of the most common methods of such encryption is to write text not horizontally, but vertically. Composed with fixed height and variable length. The necessary information is recorded vertically. As it reaches a certain value, it is transferred to the next column. Then the table is removed, and the resulting cipher is sent to the second party. To decrypt, it is enough to know the height of the table.

If the information is very valuable and needs to be encrypted more carefully, you can use double permutation. That is, the previous method is repeated again with a change in the height of the table. In addition, in the second table you can use rows rather than columns, this will only complicate decoding. Some encrypt records in a zigzag, diagonal, or spiral pattern.

Asymmetric ciphers are those whose key is known in advance. Mainly used on the Internet. For example, digital signatures operate using asymmetric cryptosystems.

Replacing letters

The advantage of this encryption method over the previous one is that it is almost impossible to solve on your own. At the very least, it will take a very large amount of time.

The simplest way is when one letter is compared to another. For example, A=B, D=D and so on. First they write the text itself, and then replace it

Basic Cryptography Concepts

The problem of protecting information from unauthorized (unauthorized) access has become noticeably worse due to the widespread use of local and especially global computer networks.

Information protection is necessary to reduce the likelihood of leakage (disclosure), modification (deliberate distortion) or loss (destruction) of information of some value to its owner.

The problem of information security has worried people for several centuries.

According to Herodotus, already in the 5th century. BC e. transformation of information using the coding method was used.

One of the very first encryption devices was wandered which was used in the 5th century. BC. during the war of Sparta against Athens. A scytale is a cylinder on which a narrow papyrus ribbon (without gaps or overlaps) was wound turn by turn. Then the text required for transmission was written on this tape along the axis of the cylinder (in columns). The tape was unwound from the cylinder and sent to the recipient. Having received such a message, the recipient wound the tape onto a cylinder of the same diameter as the diameter of the sender's hulk. As a result, the encrypted message could be read.

Aristotle came up with the idea of ​​breaking such a cipher. He proposed making a long cone and, starting from the base, wrapping it with a tape with an encrypted message, gradually moving it to the top. In some part of the cone, sections of readable text will begin to be visible. This is how the secret size of the cylinder is determined.

Ciphers appeared in ancient times in the form of cryptograms (in Greek - secret writing). Sometimes sacred Jewish texts were encrypted using the substitution method. Instead of the first letter of the alphabet, the last letter was written, instead of the second, the penultimate one, etc. This ancient cipher was called atbash. It is known that correspondence is encrypted Julius Caesar(100-44 BC) with Cicero (106-43 BC).

Caesar Cipher is implemented by replacing each letter in the message with another letter of the same alphabet, spaced from it in the alphabet by a fixed number of letters. In his ciphers, Caesar replaced the letter of the original plaintext with a letter three positions ahead of the original letter.

In Ancient Greece (II century BC) a cipher was known that was created using Polybius square. The encryption table was a square with five columns and five rows, which were numbered from 1 to 5. One letter was written in each cell of such a table. As a result, each letter corresponded to a pair of numbers, and encryption was reduced to replacing the letter with a pair of numbers.

We illustrate the idea of ​​Polybius's square with a table with Russian letters. The number of letters in the Russian alphabet differs from the number of letters in the Greek alphabet, therefore the size of the table was chosen differently (square 6 x 6). Note that the order of the symbols in the Polybius square is secret information (key).

Let's encrypt the word CRYPTOGRAPHY using the Polybius square:

26 36 24 35 42 34 14 36 11 44 24 63

The example shows that in the ciphergram the row number is indicated first, and the column number second. In a Polybius square, columns and rows can be marked not only with numbers, but also with letters.

Currently dealing with information security issues cryptology(kryptos - secret, logos - science). Cryptology is divided into two areas - cryptography and cryptanalysis. The goals of these two branches of cryptology are directly opposite.

Cryptography- the science of protecting information from unauthorized receipt by unauthorized persons. The area of ​​interest of cryptography is the development and research of information encryption methods.

Under encryption means such a transformation of information that makes the original data unreadable and difficult to disclose without knowledge of special secret information - key IN As a result of encryption, the plaintext turns into a ciphergram and becomes unreadable without the use of a decryption transformation. Ciphergram May be called differently: ciphertext, cryptogram, encryption or ciphertext. The ciphergram allows you to hide the meaning of the transmitted message.

Area of ​​interest cryptanalysis the opposite is the development and research of methods for decrypting (uncovering) a ciphergram even without knowing the secret key.

Under key is understood as secret information that determines which transformation from the set of possible encryption transformations is performed in this case on the plaintext. When using a hulk, the key is the diameter of the cylinder.

Decryption- the reverse process of encryption. When decrypting using a key, the ciphertext (ciphergram, encryption) is converted into the original plaintext.

The process of cryptanalysts obtaining a clear message from a cryptogram without a previously known key is called autopsy or burglary cipher.

There are several classifications of ciphers.

Based on the nature of the key used, encryption algorithms are divided into two types: symmetrical(with one key, in another way - with a secret key) and asymmetrical(with two keys or with a public key). Asymmetric encryption and decryption algorithms are sometimes called asymmetrical.

In the first case, the sender's encryptor and the recipient's decryptor use the same key (Key 1, see figure). The encoder produces a ciphergram, which is a function of the plaintext. The specific type of conversion (encryption) function is determined by the secret key. The message recipient's decoder performs the reverse transformation of the transformation done in the encoder. The secret key is kept secret and transmitted over a channel that prevents the key from being intercepted by an enemy or commercial competitor's cryptanalyst.

In the second case (when using an asymmetric algorithm), the recipient first transmits to the sender a public key (Key 1) via an open channel, with which the sender encrypts the information. When receiving information, the recipient decrypts it using the second secret key (Key 2). Interception of the public key (Key 1) by an enemy cryptanalyst does not allow decryption of the private message, since it is decrypted only by the second secret key (Key 2). In this case, secret Key 2 is almost impossible to calculate using public Key 1.

When assessing the effectiveness of a cipher, they are usually guided by the Dutch Auguste rule Kerkhoff(1835-1903), according to which the strength of a cipher is determined only by the secrecy of the key, i.e. the cryptanalyst knows all the details of the process (algorithm) of encryption and decryption, but it is not known which key was used to encrypt a given text.

Cryptographic strength is a characteristic of a cipher that determines its resistance to decryption without knowing the key (i.e., resistance to cryptanalysis). There are several indicators of cryptographic strength, including the number of all possible keys and the average time required for cryptanalysis.

Public key encryption algorithms use what are called irreversible or one-way functions. These functions have the following property: given the argument value X It's relatively easy to calculate the value of a function f(x). However, if the value of the Function is known y =f(x), then there is no easy way to calculate the value of the argument X.

All public key cryptosystems currently in use rely on one of the following types of irreversible transformations.

1. Factoring large numbers into prime factors (algorithm RSA, authors - Rivest, Shamir and Adleman - Rivest, Shamir, Adleman).

2. Calculation of the logarithm or exponentiation (DH algorithm, authors - Diffie and Hellman).

3. Calculation of roots of algebraic equations.

Let's consider the simplest example of “irreversible” functions. It’s easy to find in your head the product of two prime numbers 11 and 13. But try quickly in your head to find two prime numbers whose product is 437. Similar difficulties arise when using computer technology to find two prime factors for a very large number: you can find the factors, but it will take a lot of time.

Thus, the RSA factorization encoding system uses two different keys: one to encrypt the message, and a second, different but related to the first, to decrypt. The encryption key (public, non-secret key) is based on the product of two huge prime numbers, and the decryption key (private, secret key) is based on the prime numbers themselves.

Note that the operation of factoring a prime number is sometimes called factorization.

The term "irreversible" functions is unfortunate. It would be more correct to call them fast (or simply) irreversible functions. However, this term is well-established, and inaccuracy has to be tolerated.

In the 40s of the XX century. American engineer and mathematician Claude Shannon proposed developing a cipher in such a way that its solution would be equivalent to solving a complex mathematical problem. Moreover, the complexity of the problem must be such that the volume of necessary calculations exceeds the capabilities of modern computers.

In asymmetric systems, it is necessary to use long keys (2048 bits or more). A long key increases the encryption time of a clear message. In addition, key generation becomes very time-consuming. But you can send public keys over unprotected (unclassified, open) communication channels. This is especially convenient, for example, for commercial partners separated by large distances. It is convenient to transfer the public key from the banker to several investors at once.

IN symmetrical algorithms use shorter keys, so encryption and decryption are faster. But in such systems, distributing keys is a complex procedure. Keys must be transferred through closed (secret) channels. Using couriers to distribute private keys is expensive, complex and slow.

In the United States, the most widely used standard for transmitting secret messages is DES (Data Encryption Standard).

The DES standard is a block cipher. It encrypts data in 64-bit blocks. Encryption uses a 56-bit key. This standard has been subjected to multiple detailed cryptanalysis. To hack it, specialized computers were developed that cost up to $20 million. Methods for forcefully breaking the DES standard have been developed based on distributed computing using multiple computers. To increase cryptographic strength, a DES encryption method using three keys was subsequently developed - the so-called “triple DES”.

It can be argued that for many years the decryption of cryptograms has been helped by frequency analysis the appearance of individual characters and their combinations. The probabilities of individual letters appearing in text vary greatly. For the Russian language, for example, the letter “o” appears 45 times more often than the letter “f” and 30 times more often than the letter “e”. By analyzing a sufficiently long text encrypted by the replacement method, it is possible to perform a reverse replacement based on the frequencies of occurrence of characters and restore the original plaintext. The table shows the relative frequencies of appearance of Russian letters.

Letter Frequency Letter Frequency Letter Frequency Letter Frequency
O 0.09 V 0.038 h 0.016 and 0.007
her 0.072 l 0.035 s 0.016 w 0.006
A 0.062 To 0.028 b 0.014 Yu 0.006
And 0.062 m 0.026 ь, ъ 0.014 ts 0.004
n 0.053 d 0.025 G 0.013 sch 0.003
T 0.053 P 0.023 h 0.012 uh 0.003
With 0.045 at 0.021 And 0.01 f 0.002
R 0.04 I 0.018 X 0.009

The relative frequency of occurrence of a space or punctuation mark in the Russian language is 0.174. The given numbers mean the following: among 1000 letters of text, on average there will be 174 spaces and punctuation marks, 90 letters “o”, 72 letters “e”, etc.

When conducting cryptanalysis, you need to decide from a small piece of text whether the decrypted text is a meaningful message or a set of random characters. Often, cryptanalysts break ciphers on a computer using key enumeration. It is impossible to manually analyze multiple fragments of decrypted texts. Therefore, the problem of identifying meaningful text (i.e., detecting correctly deciphered text) is solved using a computer. In this case, theoretical principles developed at the end of the 19th century are used. St. Petersburg Mathematician A.A. Markov, so-called Markov chains.

It should be noted that, according to some experts, there are no unbreakable ciphers. You can declassify (break) any ciphergram either in a long time or for a lot of money. In the second case, decryption will require the use of several supercomputers, which will lead to significant material costs. Increasingly, distributed Internet resources are used to crack secret messages, parallelizing calculations and involving hundreds and even thousands of workstations in the calculations.

There is another opinion. If the length of the key is equal to the length of the message, and the key is generated from random numbers with an equally probable distribution and changes with each new message, then the cipher cannot be cracked even theoretically. A similar approach was first described by G. Vernam at the beginning of the 20th century, proposing the one-time pad algorithm.

Let's consider another classification of ciphers.

Many modern encryption methods can be divided into four large groups: methods replacements(substitutions), permutations, additive(gamming) and combined methods.

In code permutations all letters of the plaintext remain unchanged, but are moved from their original positions to other places (an example is encryption using a scytale).

The following simplest “ciphering” was obtained by rearranging two adjacent letters RKPIOTRGFAYAI.

In this “secret” message it is easy to recognize the word CRYPTOGRAPHY.

A more complex permutation algorithm comes down to dividing the message into groups of three letters. In each group, the first letter is placed in third place, and the second and third letters are shifted one position to the left. The result is a cryptogram: RICTOPRAGIYAF.

Permutations are obtained by writing the original text and reading the ciphertext along different paths of some geometric figure.

In code replacements the positions of the letters in the cipher remain the same as in the plaintext, but the plaintext characters are replaced by characters from a different alphabet. An example is the Polybius square. Here the letters are replaced by the corresponding numbers.

The replacement method is often implemented by many users accidentally when working on a computer. If, due to forgetfulness, you do not switch the case on the keyboard from Latin to Cyrillic, then instead of letters of the Russian alphabet, when entering text, letters of the Latin alphabet will be printed. As a result, the original message will be “encrypted” in Latin letters. For example, rhbgnjuhfabz - this is how the word cryptography is encrypted.

IN additive In this method, the letters of the alphabet are first replaced by numbers, to which the numbers of a secret pseudo-random number sequence (gamma) are then added. The composition of the scale varies depending on the key used. Typically, the logical operation “Exclusive OR” is used for encryption. During decryption, the same gamma is applied to the encrypted data. The gamma method is widely used in military cryptographic systems. Ciphers obtained by the additive method are sometimes called stream ciphers.

Combined methods involve using several methods at once to encrypt a message (for example, first replacing characters and then rearranging them).

There is another approach to transmitting secret messages. It comes down to concealing the very fact of transmitting information. Science deals with such encryption methods steganography.

If cryptography makes an open message unreadable without knowing the secret key, then steganography develops encryption methods that make it difficult to notice the very fact of transmitting information.

Steganography uses special containers in which the transmitted message is hidden. For example, secret text is embedded in a harmless design of a flower on a greeting card.


Encrypting messages using various methods

Instead of a tail there is a leg, and on the leg there are horns.

L. Derbeneev.

Let's look at how to encrypt a message method substitution (in other words, the substitution method). First we use the Caesar cipher. Let's say you want to encrypt the message "WHERE IS ABBA".

As is known, the cyclic Caesar cipher is obtained by replacing each letter of the plaintext with letters of the same alphabet, located in front through a certain number of positions, for example, through three positions. Cyclic it is called because when a replacement is performed, the last letter of the alphabet is again followed by the first letter of the alphabet. Let's write down fragments of the Russian alphabet and show how encryption is performed (replacement order):

As a result of the transformation, the following ciphergram will be obtained:

YOZHZ GDDG.

In this case, the key is the shift amount (the number of positions between letters). The number of keys in this cipher is small (it is equal to the number of letters of the alphabet). It is not difficult to open such a ciphergram by searching through all possible keys. The disadvantage of the Caesar cipher is its low cryptographic strength. This is explained by the fact that in the encrypted text the letters are still arranged in alphabetical order, only the starting point is shifted by several positions.

Replacement can be carried out with characters of a different alphabet and with a more complex key (replacement algorithm). For simplicity, we again present only the initial parts of the alphabets. The lines show the order of replacing letters of the Russian alphabet with letters of the Latin alphabet. Let's encrypt the phrase “WHERE IS ABBA”

The result of this encryption is the following cryptogram:

It is more rational to write the key used in the latter case in the form of a table:

A B IN G D E
E F A WITH D IN

When encrypting, letters can be replaced by numbers (in the simplest case, the serial numbers of letters in the alphabet). Then our encryption will look like this:

Plaintext characters can be replaced with special characters, for example, with “dancing men”, as in the story by K. Doyle, or with the help of flags, as is done by sailors.

They have higher cryptographic strength compared to the Caesar cipher. affine cryptosystems.

In affine cryptosystems, due to mathematical transformations, the letters that replace the plaintext are chaotically mixed. In affine cryptosystems, the letters of the plaintext are numbered, for example, for the Cyrillic alphabet from 0 to 32. Each letter of the plaintext is then replaced by a letter, the serial number of which is calculated using a linear equation and calculating the remainder of integer division.

Affine cryptosystems are defined using two numbers A and b . For the Russian alphabet, these numbers are selected from the condition a ≥ 0, b≤ 32. The maximum number of characters in the alphabet used is indicated by the symbol γ. Moreover, the numbers A and γ = 33 must be relatively prime. If this condition is not met, then two different letters can be displayed (turned) into one. Each plaintext letter code μ is replaced by a cryptogram letter code according to the following rule. First, the number α= a∙μ + b is calculated , and then the operation of integer division of the number α by the number γ = 33 is performed, that is, α= β(mod (γ)). The remainder of the integer division is used as the code of the Ciphergram symbol. To be specific, let’s choose the following numbers: A= 5 and b=3. A fragment of the procedure illustrating the encryption procedure is given in the table.

In the ciphers we previously considered, each letter of the plaintext corresponded to one specific letter of the cryptogram. Such ciphers are called ciphers mono-alphabetic replacement.

Long messages received using the mono-alphabetic replacement method (another name is simple cipher single letter replacements), are revealed using tables of relative frequencies. To do this, the frequency of occurrence of each symbol is calculated and divided by the total number of symbols in the ciphergram. Then, using a table of relative frequencies, it is determined which replacement was made during encryption.

Increase cryptographic strength polyalphabetic ciphers substitutions (or multi-valued substitution ciphers). In this case, each symbol of the open alphabet is associated with not one, but several encryption symbols.

Below is a fragment of the polyalphabetic replacement key:

A B IN G D E

Using a multi-alphabetic cipher, the message “WHERE IS ABBA” can be encrypted in several ways:

19-83-32-48-4-7-12,

10-99-15-12-4-14-12, etc.

For each letter of the original alphabet, a certain set of ciphergram symbols is created so that the sets of each letter do not contain identical elements. Multi-alphabetic ciphers change the pattern of statistical frequencies of occurrence of letters and thereby make it difficult to break the cipher without knowing the key.

Let's consider another polyalphabetic substitution cipher, which was described in 1585 by the French diplomat Blaise de Vigenère. Encryption is performed using the so-called Vigenère table. Here, as before, only part of the table is shown in order to present only the idea of ​​the method.

Each row in this table corresponds to one simple substitution cipher (such as a Caesar cipher). When encrypting, the open message is written on a line, and the key is placed under it. If the key is shorter than the message, then the key is repeated cyclically. The encryption is obtained by finding the symbol in the matrix of letters of the ciphergram. The cipher symbol is located at the intersection of the column with the plaintext letter and the row with the corresponding key letter.

Let's say you want to encrypt the message "WHERE IS ABBA". Let’s choose the word “VIRGO” as the key. As a result we get:

YAYAG AYEW.

System Playfair creates multi-alphabetic ciphers. Let's consider the basic idea of ​​this system.

Encryption is performed using a square (or rectangle) containing the letters of the corresponding national alphabet. The letters are written in a square or rectangle in any order. This letter order and table configuration is the secret key. To be specific, let’s take a rectangular table measuring 8x4, use the Cyrillic alphabet as the letters of the alphabet, and arrange the letters in alphabetical order. Since the number of Russian letters is 33, and the number of cells is 32, we will exclude the letter E from the table.

Let's assume that you want to encrypt the word CRYPTOGRAPHY. Let's look at the encryption rules.

1. The plaintext is divided into blocks of two letters. Letters in one block should not be the same. Let's divide the original word into blocks of two letters KR-IP-TO-GR-AF-YA.

2. If the letters of the encrypted block are in different rows and columns, then the letters located in the corners of the rectangle enclosing the plaintext letters are used as replacement letters. For example, the KR block is replaced with IT symbols.

3. If the letters of the plaintext fall on one line, then the ciphergram is obtained by cyclically shifting to the right one cell. For example, the IP block will be converted to YI. Another example for this rule. If, suppose, it is necessary to transform the KN block, then the result will be LO.

4. If both letters of the plaintext fall into the same column, then a cyclic shift is performed one cell down for encryption.

The LifeCenter block will be converted into OYU symbols, and the ТЪ block into ЪВ Symbols.

In accordance with the described rules, the word CRYPTOGRAPHY will be converted into the ITYITSKAUDRPSH cryptogram.

Note that if the plaintext blocks consist of the same letters, then the cryptogram will also contain the same pairs of characters. For this reason, the considered cipher is mono-alphabetic. However, modification of this cipher turns it into a multi-alphabetic system. To do this, several Playfair tables are used and multiple encryption is performed.

Here it is appropriate to consider the cryptographic system Hilla, in which encryption is carried out using mathematical transformations: calculations using linear algebra techniques.

This cipher for a single letter can be considered multi-alphabetic. However, pairs of letters are encrypted the same way everywhere. Therefore, in a broad sense, the Hill cryptographic system should be classified as a mono-alphabetic cipher.

The original plaintext should be converted into a collection of numbers using the replacement method. Let's assume that a text written using 26 Latin letters is encrypted. We will choose the following algorithm for replacing letters with numbers: we will replace the Latin letters A, B, C, D, ..., Z with the numbers 1, 2, 3, 4, ..., 26, respectively. In other words: we will number the letters in the order of their location in the alphabet, and when replacing we will use their serial numbers. In this case, such a replacement algorithm was chosen, but it is clear that it can be anything.

Let's assume that we need to encrypt the German word ZEIT. Let's replace the letters in accordance with their serial numbers in the alphabet with four numbers: 26 - 5 - 9 - 20.

Next you need to choose a number d > 2. This number shows the order in which the plaintext is divided into groups of characters (determines how many letters there will be in each group). From a mathematical point of view, the number d shows how many rows there should be in column vectors. Let's accept d= 2. This means that the numbers 26 - 5 - 9 - 20 need to be divided into groups of two numbers in each group and written as column vectors:

Let's look at examples of message encryption using the method permutations.

The idea of ​​this cryptography method is that the plaintext is written and the encryption is subsequently read along different paths of some geometric figure (for example, a square).

To explain the idea, let's take a square table (matrix) 8x8. We will write the text sequentially in rows from top to bottom, and read it in columns sequentially from left to right.

Suppose you want to encrypt a message:

IT'S HARD TO STUDY IN THE FIRST YEAR ONLY THE FIRST FOUR YEARS OF THE DEAN'S STUDY.

n A _ P E R V ABOUT
m To U R WITH E _
T I and E L ABOUT _ U
h AND T b WITH I _ T
ABOUT L b TO ABOUT _ P E
R V s E _ H E T
s R E _ G ABOUT d A
_ d E TO A n A T

In the table, the symbol “_” indicates a space.

As a result of the transformations, the encryption will be

NMTCHORY_A_YAILVRD_KZHTYEPUUEKE_KERLSO_GARSOYA_CHONVE_

PEDAO_UTETAT.

As you can see from the example, the encryption and plaintext contain the same characters, but they are located in different places.

The key in this case is the size of the matrix, the order in which the plaintext is written and the ciphergram is read. Naturally, the key may be different. For example, writing plaintext by rows can be done in the following order: 48127653, and reading a cryptogram can be done by columns in the following order: 81357642.

We will call the order of writing into the rows of the matrix the write key, and the order of reading the ciphergram in the columns - the read key.

Then the rule for deciphering a cryptogram obtained by the permutation method can be written as follows.

To decrypt a cryptogram obtained using a matrix p x p, you need to break the cryptogram into groups of symbols according to P characters in each group. Write the leftmost group from top to bottom in a column whose number coincides with the first digit of the reading key. Write the second group of characters in a column whose number coincides with the second digit of the read key, etc. The plaintext is read from the matrix row by row in accordance with the digits of the record key.

Let's consider an example of decrypting a cryptogram obtained by the permutation method. It is known that the encryption uses a 6x6 matrix, a write key of 352146 and a read key of 425316. The text of the ciphergram is as follows:

DKAGCHYOVA_RUAAKOEBZERE_DSOHTESE_T_LU

Let's divide the ciphergram into groups of 6 characters:

DKAGCH OVA_RU AAKOEB ZERE_D SOKHTES E_T_LU

Then we write the first group of characters in column 4 of the 6x6 matrix, since the first digit of the reading key is 4 (see Figure a). We will write the second group of 6 symbols in column 2 (see Figure b), the third group of symbols in column 5 (see Figure c), skipping two phases of filling the matrix, we will depict a completely filled matrix (see Figure d).

We start reading the plaintext according to the write key from line 3, then use line 5, etc. As a result of decryption, we obtain the plaintext:

A MAN'S CHARACTER CREATES HIS DESTINY

Naturally, the described procedure for decrypting a cryptogram is performed automatically by a computer using pre-developed programs.


D
TO
A
G
h
b
ABOUT d
IN To
A A
G
R h
U b

ABOUT D A
IN TO A
A A TO
G ABOUT
R h E
U b B
WITH ABOUT d A E
ABOUT IN E To A
X A R A TO T
T E G ABOUT
E R h E L
WITH U d b B U

To increase cryptographic strength, substitution and permutation methods are often used in combination with the additive method.

©2015-2019 site
All rights belong to their authors. This site does not claim authorship, but provides free use.
Page creation date: 2016-04-11

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: 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 made great progress 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 in 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.

The problem of personal data theft has quietly become a scourge of civilization. Information about the user is obtained by all and sundry: some have previously sought consent (social networks, operating systems, computer and mobile applications), others without permission or demand (attackers of all kinds and entrepreneurs who derive any benefit from information about a specific person). In any case, it’s not a pleasant experience and there is always a risk that, along with harmless information, something will fall into the wrong hands that can harm you personally or your employer: official documents, private or business correspondence, family photos...

But how to prevent leaks? A tin foil hat will not help here, although it is undoubtedly a beautiful solution. But total data encryption will help: having intercepted or stolen encrypted files, the spy will not understand anything about them. This can be done by protecting all your digital activity using strong cryptography (strong ciphers are those that, with existing computer power, will take time to crack, at least longer than a person’s life expectancy). Here are 6 practical recipes that you can use to solve this problem.

Encrypt your web browser activity. The global network is designed in such a way that your request, even to closely located sites (such as yandex.ru), passes on its way through many computers (“nodes”) that relay it back and forth. You can see an approximate list of them by entering the command tracert site_address in the command line. The first on such a list will be your Internet provider or the owner of the Wi-Fi access point through which you connected to the Internet. Then some more intermediate nodes, and only at the very end is the server on which the site you need is stored. And if your connection is not encrypted, that is, it is carried out using the usual HTTP protocol, everyone who is between you and the site will be able to intercept and analyze the data being sent.

So do a simple thing: add an “s” to “http” in the address bar so that the site address begins with “https://”. This way you will enable traffic encryption (the so-called SSL/TLS security layer). If the site supports HTTPS, it will allow this. And in order not to suffer every time, install a browser plugin: it will forcefully try to enable encryption on every site you visit.

Flaws: The spy will not be able to find out the meaning of the data being transmitted and received, but he will know that you visited a specific site.

Encrypt your email. Letters sent by e-mail also go through intermediaries before reaching the recipient. By encrypting, you will prevent the spy from understanding their contents. However, the technical solution here is more complex: you will need to use an additional program for encryption and decryption. The classic solution, which has not lost its relevance to this day, would be the OpenPGP package or its free analogue GPG, or a browser plugin that supports the same encryption standards (for example, Mailvelope).

Before you start correspondence, you generate a so-called public cryptokey, which your recipients can use to “close” (encrypt) letters addressed to you. In turn, each of your recipients must also generate their own key: using other people’s keys, you can “close” letters for their owners. To avoid confusion with keys, it is better to use the above-mentioned browser plugin. A letter “closed” with a crypto key turns into a set of meaningless symbols - and only the owner of the key can “open” it (decrypt it).

Flaws: When starting a correspondence, you must exchange keys with your correspondents. Try to ensure that no one can intercept and replace the key: pass it from hand to hand, or publish it on a public key server. Otherwise, by replacing your key with his own, the spy will be able to deceive your correspondents and will be aware of your correspondence (the so-called man in the middle attack).

Encrypt instant messages. The easiest way is to use instant messengers that can already encrypt correspondence: Telegram, WhatsApp, Facebook Messenger, Signal Private Messenger, Google Allo, Gliph, etc. In this case, you are protected from prying eyes from the outside: if a random person intercepts messages, he will only see a jumble of symbols. But this will not protect you from the curiosity of the company that owns the messenger: companies, as a rule, have keys that allow you to read your correspondence - and not only do they like to do this themselves, they will hand them over to law enforcement agencies upon request.

Therefore, the best solution would be to use some popular free (open source) messenger with a connected plugin for on-the-fly encryption (such a plugin is often called “OTR”: off the record - preventing recording). A good choice would be Pidgin.

Flaws: As with email, you are not guaranteed against a man-in-the-middle attack.


Encrypt documents in the cloud. If you use cloud storage services like Google Drive, Dropbox, OneDrive, iCloud, your files may be stolen by someone who snoops (or guesses) your password, or if some kind of vulnerability is discovered in the service itself. So before you put anything in the cloud, encrypt it. The easiest and most convenient way to implement such a scheme is to use a utility that creates a folder on your computer - documents placed there are automatically encrypted and forwarded to a “cloud” drive. This is, for example, Boxcryptor. It is a little less convenient to use applications like TrueCrypt for the same purpose - they create an entire encrypted volume located in the cloud.

Flaws: none.


Encrypt all (not just browser) traffic from your computer. It can be useful if you are forced to use an unverified open Internet connection - for example, unencrypted Wi-Fi in a public place. Here it is worth using a VPN: to simplify somewhat, this is an encrypted channel extended from you to the VPN provider. On the provider's server, the traffic is decrypted and sent further to its destination. VPN providers are both free (VPNbook.com, Freevpn.com, CyberGhostVPN.com) and paid - varying in access speed, session time, etc. The big bonus of this connection is that to the world you appear to be accessing the Internet from the VPN server, and not from your computer. Therefore, if the VPN provider is located outside the Russian Federation, you will be able to access sites blocked within the Russian Federation.

The same result can be achieved if you install TOR on your computer - the only difference is that in this case there is no provider: you will access the Internet through random nodes belonging to other participants in this network, that is, persons or organizations unknown to you.

Flaws: Remember that your traffic is decrypted at the exit node, that is, on the server of the VPN provider or the computer of a random TOR participant. Therefore, if their owners wish, they will be able to analyze your traffic: try to intercept passwords, extract valuable information from correspondence, etc. Therefore, when using VPN or TOR, combine them with other encryption tools. In addition, setting up TOR correctly is not an easy task. If you do not have experience, it is better to use a ready-made solution: the TOR kit + Firefox browser (in this case, only browser traffic will be encrypted) or the Tails Linux distribution (working from a CD or flash drive), where all traffic is already configured to be routed through TOR .

Encrypt flash drives and removable storage media, mobile devices. You can also add encryption of the hard drive on your work computer, but at least you don’t risk losing it - the possibility of which is always present in the case of portable drives. To encrypt not a single document, but an entire disk at once, use the applications BitLocker (built into MS Windows), FileVault (built into OS X), DiskCryptor, 7-Zip and the like. Such programs work “transparently,” that is, you will not notice them: files are encrypted and decrypted automatically, “on the fly.” However, an attacker who gets his hands on a flash drive sealed with their help, for example, will not be able to extract anything from it.

As for smartphones and tablets, for full encryption it is better to use the built-in functionality of the operating system. On Android devices, look at “Settings -> Security”, on iOS in “Settings -> Password”.

Flaws: Since all data is now stored in encrypted form, the processor has to decrypt it when reading and encrypt it when writing, which, of course, wastes time and energy. Therefore, the drop in performance can be noticeable. How much your digital device will actually slow down depends on its specifications. In general, more modern and top-end models will perform better.


This is a list of actions that you should take if you are concerned about the possible leakage of files into the wrong hands. But besides this, there are a few more general considerations that should also be kept in mind:

A free privacy app is usually more reliable than a proprietary one. Free is something whose source code is published under a free license (GNU GPL, BSD, etc.) and can be changed by anyone. Proprietary - one for which exclusive rights belong to any one company or developer; The source code for such programs is usually not published.

Encryption involves the use of passwords, so make sure your password is correct: long, random, varied.

Many office applications (text editors, spreadsheets, etc.) can encrypt their documents themselves. However, the strength of the ciphers they use is usually low. Therefore, for protection, it is better to prefer one of the universal solutions listed above.

For tasks that require anonymity/privacy, it is more convenient to keep a separate browser configured for “paranoid” mode (like the already mentioned Firefox + TOR bundle).

Javascript, often used on the Internet, is a real boon for a spy. Therefore, if you have something to hide, it is better to block Javascript in your browser settings. Also, be sure to block ads (install any plugin that implements this function, for example, AdBlockPlus): lately, malicious code has often been sent out under the guise of banners.

If the notorious “Yarovaya law” does come into force (according to the plan, this should happen on July 1, 2018), spare keys for all ciphers in Russia will have to be transferred to the state, otherwise the cipher will not be certified. And for using uncertified encryption, even ordinary smartphone owners can be fined in the amount of 3 thousand rubles with confiscation of the digital device.

P.S. This article uses a photograph by Christiaan Colen.

If you liked the article, recommend it to your friends, acquaintances or colleagues related to municipal or public service. It seems to us that it will be both useful and pleasant for them.
When reprinting materials, reference to the original source is required.

My memories from childhood + imagination were enough for exactly one quest: a dozen tasks that are not duplicated.
But the children liked the fun, they asked for more quests and had to go online.
This article will not describe the script, legends, or design. But there will be 13 ciphers to encode the tasks for the quest.

Code number 1. Picture

A drawing or photo that directly indicates the place where the next clue is hidden, or a hint at it: broom + socket = vacuum cleaner
Complication: make a puzzle by cutting the photo into several parts.


Code 2. Leapfrog.

Swap the letters in the word: SOFA = NIDAV

Cipher 3. Greek alphabet.

Encode the message using the letters of the Greek alphabet, and give the children the key:

Code 4. Vice versa.

Write the assignment backwards:

  • every word:
    Etishchi dalk extra Jonsos
  • or an entire sentence, or even a paragraph:
    Etsem morkom momas v - akzaksdop yaaschuudelS. itup monrev an yv

Code 5. Mirror.

(when I did the quest for my children, at the very beginning I gave them a “magic bag”: there was a key to the “Greek alphabet”, a mirror, “windows”, pens and sheets of paper, and all sorts of unnecessary things for confusion. Finding the next riddle , they had to figure out for themselves what from the bag would help them find the answer)

Code 6. Rebus.

The word is encoded in pictures:



Cipher 7. Next letter.

We write a word, replacing all the letters in it with the following ones in alphabetical order (then I is replaced by A, in a circle). Or the previous ones, or the next ones after 5 letters :).

CABINET = SHLBH

Code 8. Classics to the rescue.

I took a poem (and told the children which one) and a code of 2 numbers: line number number of letters in the line.

Example:

Pushkin "Winter Evening"

The storm covers the sky with darkness,
Whirling snow whirlwinds;
Then, like a beast, she will howl,
Then he will cry like a child,
Then on the dilapidated roof
Suddenly the straw will rustle,
The way a belated traveler
There will be a knock on our window.

21 44 36 32 82 82 44 33 12 23 82 28

Did you read it, where is the hint? :)

Code 9. Dungeon.

Write the letters in a 3x3 grid:

Then the word WINDOW is encrypted like this:

Code 10. Labyrinth.

My children liked this code; it is unlike the others, because it is not so much for the brain as for attention.

So:

On a long thread/rope you attach the letters in order, as they appear in the word. Then you stretch the rope, twist it and entangle it in every possible way between the supports (trees, legs, etc.). Having walked along the thread, as if through a maze, from the first letter to the last, the children will recognize the clue word.

Imagine if you wrap one of the adult guests in this way!
Children read - The next clue is on Uncle Vasya.
And they run to feel Uncle Vasya. Eh, if he is also afraid of tickles, then everyone will have fun!

Code 11. Invisible ink.

Use a wax candle to write the word. If you paint over the sheet with watercolors, you can read it.
(there are other invisible inks... milk, lemon, something else... But I only had a candle in my house :))

Code 12. Rubbish.

The vowels remain unchanged, but the consonants change according to the key.
For example:
SHEP SCHOMOZKO
reads as - VERY COLD, if you know the key:
D L X N H
Z M SCH K V

Code 13. Windows.

The kids loved it incredibly! They then used these windows to encrypt messages to each other all day long.
So: on one sheet of paper we cut out windows, as many as there are letters in the word. This is a stencil, we apply it to a blank sheet of paper and write a clue word in the windows. Then we remove the stencil and write many different unnecessary letters on the remaining blank space of the sheet. You can read the code if you attach a stencil with windows.
The children were at first stupefied when they found a sheet covered with letters. Then they twisted the stencil back and forth, but you still need to put it on the right side!

Code 14. Map, Billy!

Draw a map and mark (X) the location with the treasure.
When I did the quest for mine for the first time, I decided that the map was very simple for them, so I needed to make it more mysterious (then it turned out that just a map would be enough for the children to get confused and run in the opposite direction)...

This is the map of our street. Hints here are house numbers (to understand that this is actually our street) and huskies. This dog lives with a neighbor across the street.
The children did not immediately recognize the area and asked me leading questions..
Then 14 children took part in the quest, so I united them into 3 teams. They had 3 versions of this map and each one had its place marked. As a result, each team found one word:
"SHOW" "FAIRY TALE" "TURNIP"
This was the next task :). He left behind some hilarious photos!
For my son’s 9th birthday, I didn’t have time to invent a quest, so I bought it on the MasterFuns website.. At my own peril and risk, because the description there is not very good.
But my children and I liked it because:
  1. inexpensive (similar to about 4 dollars per set)
  2. quickly (paid - downloaded, printed - everything took 15-20 minutes)
  3. There are a lot of tasks, with plenty to spare. And although I didn’t like all the riddles, there was plenty to choose from, and you could enter your own task
  4. everything is decorated in the same monster style and this gives the holiday effect. In addition to the quest tasks themselves, the kit includes: a postcard, flags, table decorations, and invitations to guests. And it's all about monsters! :)
  5. In addition to the 9-year-old birthday boy and his friends, I also have a 5-year-old daughter. The tasks were beyond her, but she and her friend also found entertainment - 2 games with monsters, which were also in the set. Phew, in the end - everyone is happy!

Return

×
Join the “koon.ru” community!
In contact with:
I am already subscribed to the community “koon.ru”