Basic concepts of cryptography


The article directories


preface

Passwords play an important role in our lives. Where do they come from and why do they come into being?

Cryptography has a history of thousands of years. It has experienced three stages, classical cryptography, modern cryptography and modern cryptography, from the substitution method at the beginning to the asymmetric encryption algorithm today. Cryptography is not only the wisdom of mathematicians, but also an important foundation for cyberspace security today.

Cryptography is the basis of network security, information security, blockchain and other products. Common asymmetric encryption, symmetric encryption, hash function, etc., all belong to the category of cryptography.


First, classical cryptography

In ancient wars, it is common to use hidden information to protect important communication data. For example, the information that needs to be protected is written on the paper with chemical potions. After the potions are dry, no information can be seen on the paper, and the information on the paper can only be read after the application of other chemical potions.

Beauty drops the potion on the paper, but the paper shows the writing, this is too magical! Video address :www.iqiyi.com/v_19rt6ab1h…

These methods are to protect important information from others, but the way of hiding information is easy to be discovered by others. For example, increasing the investigation of sentinels will find the trick, so the later development of classical cryptography is difficult to crack.

1. The substitution method

Substitution is easy to understand, which is to replace the original text with a fixed message in ciphertext that cannot be read directly. For example, by substituting B for W and e for P, the word bee becomes WPP, and people who do not know the substitution rules cannot read the original text.

The substitution method has two forms: single table substitution and multiple table substitution. Single-table replacement means that there is only one ciphertext comparison form, which is used by sender and receiver for encryption and decryption. In the example above, the form is: A B C D e-s W T r P.

Multi-table replacement means that there are multiple ciphertext comparison forms of the original text, and different letters can be replaced with the contents of different forms.

For example, form 1: abcde-swtrp, form 2: abcde-chfhk, and form 3: abcde-jftou.

Specify a third form for the first letter, a first form for the second letter, and a second form for the third letter, and the word bee becomes

(312) FPK, which is more difficult to crack, 312 is also called the key, the key can be agreed in advance, or can be marked in the transmission process.

2. The displacement method

Shift method is all the letters in the original text in the alphabet backward (or forward) according to a fixed number of offset after the ciphertext, the typical shift method application is “Caesar password”.

For example, the convention is to move backwards by two bits (abcde-cdefg) so that the bee word changes to DGG.

The same substitution method, the shift method can also use the way of multi-table shift, the typical case of multi-table is the “Vignia password” (also translated by The Vernal password), which belongs to a form of multi-table password.



\

3. Classical password cracking

Classical ciphers, though simple, were the oldest form of encryption in the history of cryptography, until the mathematical methods of “probability theory” were discovered and cracked. \

The frequency of letters in English words is different. E accounts for the highest percentage of 12.702%, while Z only accounts for 0.074%. If you are interested, you can check the detailed statistics of letter frequency in encyclopaedia. If the number of ciphertext is large enough, only frequency analysis can be used to crack the single-table substitution or shift method. \

Although the replacement method or shift method of multiple tables is more difficult, but if the amount of data is large enough, it can also be cracked. Take the Vinegia cipher algorithm as an example. The cracking method is to first find out the identical letter strings in the ciphertext, guess the key length, and then put the ciphertext of the same group together and use the frequency analysis method to crack.

Modern cryptography

The security of classical ciphers was threatened, coupled with the low convenience of using them, and modern ciphers became widely used in the industrial age.

The Enigma machine

The Enigma machine was an encryption machine used by Nazi Germany during World War II. It was later broken by the British, and was deciphered by Alan Turing, the father of computer science and artificial intelligence.



The Enigma machine

The encryption method used by the Enigma machine is still shift and substitution in nature, but because of the wide variety of cipher tables, difficult to crack, and encryption and decryption machine, easy to use, so it was used in world War II.

Modern cryptography

1. Hash functions

The hash function, also known as the hash function, digest function or hash function, can transform the message of any length into a fixed length value after operation. The common ones are MD5, SHA-1 and SHA256, which are widely used in file verification and digital signature.

MD5 can generate a 128-bit (16-byte) hash of any length of text

Sha-1 can generate a 160-bit (20-byte) hash of any length of text

2. Symmetric passwords

Symmetric ciphers use the same encryption key and decryption key. Symmetric ciphers are divided into sequence ciphers (stream ciphers) and block ciphers (block ciphers). Stream ciphers encrypt every element (a letter or a bit) in an information stream as a basic processing unit, while block ciphers first block the information stream and then encrypt each piece separately.

For example, if the source text is 1234567890, flow encryption is performed on 1, 2, and 3…… Finally spliced into ciphertext; Block encryption is divided into different blocks, for example, 1234, 5678, and 90XX(XX is a complement number). Then, different blocks are encrypted and finally spliced into ciphertext. The classical cryptographic encryption methods mentioned above all belong to stream encryption.

3. Asymmetric passwords

The key security of symmetric cipher is extremely important. The cipher and the decryptor need to negotiate the key in advance and ensure the security of the key respectively. Once the key is leaked, even if the algorithm is secure, the privacy of the original information cannot be guaranteed.

In practice, the remote pre-negotiation key is not easy to be realized. Even if the negotiation is good, it is easy to be obtained by others in the process of remote transmission. Therefore, asymmetric keys have prominent advantages.

Asymmetric passwords have two keys, publickey and privatekey. Encryption and decryption use different keys. After the original text is encrypted with the public key, it needs to be decrypted by the private key. After the original text is encrypted with the private key (generally called signature), it needs to be decrypted with the public key (generally called signature check). If the public key can be made public, the user encrypts the information with the public key and sends it to the private key holder, who decrypts the information with the private key to obtain the original information. Because the private key is only held by a single person, there is no fear of someone decrypting the text of the message.


Summary: How to set a password to secure

  • Don’t use common passwords. Don’t use common passwords like type 123456.
  • You are advised to use different passwords for different application software to avoid an application database being removed from the database and all application passwords collapsing.
  • You can add the registration time, registration place, and application features when setting the password. For example, tianjin123456 indicates that the application is registered in Tianjin.