The basic concepts of cryptography (01)

Basic concepts of cryptography



Preface

Passwords play an important role in our lives, so where does the password come from and why is it generated?

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

Cryptography is the foundation of products such as network security, information security, and blockchain. Common asymmetric encryption, symmetric encryption, hash functions, etc., all belong to the category of cryptography.


1. Classical cryptography

In ancient wars, it was common to use hidden information to protect important communication data. For example, first write the information that needs to be protected with a chemical potion on paper. After the potion dries, no information can be seen on the paper. You need to use another chemical potion to apply the information before you can read the information on the paper.

The beauty sprinkled the potion on the paper, but the handwriting was displayed on the paper. This is also amazing!
Video address: https://www.iqiyi.com/v_19rt6ab1hg.html

These methods are all to protect important information from being obtained by others, but the method of hiding information is easier to be seen by others. For example, if you increase the investigation of sentinels, you will find the tricks, and then develop a more difficult to crack classical password learn.

1. Replacement method

The substitution method is easy to understand, which is to replace the original text with cipher text information that cannot be read directly with fixed information. For example, replace b with w and e with p, so that the word bee is transformed into wpp, and people who don't know the replacement rules can't read the meaning of the original text.

The replacement method has two forms: single table replacement and multiple table replacement. Single table replacement means that there is only one original ciphertext comparison form, and the sender and receiver use this form to encrypt and decrypt. In the above example, the form is: abcde-swtrp.

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

For example, the agreed form is: form 1: abcde-swtrp, form 2: abcde-chfhk, form 3: abcde-jftou.

It is stipulated that the first letter uses the third form, the second letter uses the first form, and the third letter uses the second form, then the word bee becomes

(312) fpk, which is more difficult to crack. 312 is also called a key. The key can be agreed in advance or marked during transmission.

2. Displacement method

The shift method is to shift all the letters in the original text backward (or forward) by a fixed number to obtain the ciphertext. A typical shift method uses the "Caesar cipher".

For example, it is agreed to move backward by 2 digits (abcde-cdefg), so that the word bee becomes dgg.

In the same way, the shift method can also adopt the method of multi-table shift. A typical multi-table case is the "Veniggia Code" (also translated as the Vergenal Code), which is a form of multi-table code.
Insert picture description here

3. Classical password cracking method

Although the classical cipher is very simple, it is the oldest encryption method in the history of ciphers. Until the mathematical method of "probability theory" was discovered, the classical cipher was cracked.

Insert picture description here

The frequency of letters in English words is different, e accounts for the highest percentage of 12.702%, and z only accounts for 0.074%. If you are interested, you can go to encyclopedia to check the detailed statistics of letter frequency. If the number of ciphertexts is large enough, only the frequency analysis method can be used to crack the single table replacement method or shift method.

Insert picture description here

Although the multi-table replacement method or shift method is more difficult, it can be cracked if the amount of data is large enough. Taking the Venegia cipher algorithm as an example, the cracking method is to first find out the exact same letter string in the ciphertext, guess the length of the key, and then put the ciphertexts of the same group together and use the frequency analysis method to crack.

2. Modern cryptography

The security of classical ciphers has been threatened, and the convenience of use is low. In the industrial age, modern ciphers have been widely used.

Enigma Machine

The Enigma machine was an encryption machine used by Nazi Germany during World War II. It was later deciphered by the United Kingdom. The people involved in the deciphering were Turing, known as the father of computer science and the father of artificial intelligence.
Insert picture description here
Enigma Machine

The encryption method used by the Enigma machine is essentially shifted and replaced, but because there are many types of cipher tables, it is difficult to crack, and the encryption and decryption is machined and easy to use, so it was used during World War II.

Three, modern cryptography

1. Hash function

Hash function, see also hash function, digest function or hash function, which can convert messages of any length into a fixed-length value. Common ones are MD5, SHA-1, and SHA256, which are mostly used in file verification. Signing.

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

SHA-1 can generate a 160-bit (20-byte) hash value from the original text of any length

2. Symmetric cryptography

The symmetric cipher applies the same encryption key and decryption key. Symmetric ciphers are divided into two types: sequence cipher (stream cipher) and block cipher (block cipher). The stream cipher is to encrypt each element (a letter or a bit) in the information stream as a basic processing unit. The block cipher first divides the information stream into blocks, and then encrypts each block separately.

For example, the original text is 1234567890, and the stream encryption is to encrypt 1 first, then encrypt 2, then encrypt 3... Finally, it is spliced ​​into ciphertext; block encryption is first divided into different blocks, such as 1234 into blocks, 5678 into blocks, 90XX (XX is a supplementary digit) into blocks, and then different blocks are respectively encrypted, and finally spliced ​​into ciphertext. The classical cryptographic encryption methods mentioned above all belong to stream encryption.

3. Asymmetric cryptography

The key security of symmetric ciphers is extremely important. The encryptor and 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 actual use, remote key negotiation in advance is not easy to achieve. Even if the negotiation is good, it is easy to be obtained by others during remote transmission. Therefore, asymmetric keys have their advantages at this time.

Asymmetric cryptography has two keys, a public key and a private key. The encryption and decryption operations use different keys. After encrypting the original text with the public key, it needs to be decrypted by the private key; after encrypting the original text with the private key (generally called signature at this time), it needs to be decrypted by the public key (generally called signature verification at this time). The public key can be made public. Everyone uses the public key to encrypt the information and then sends it to the holder of the private key. The holder of the private key uses the private key to decrypt the information and obtain the original information. Because the private key is only held by a single person, there is no need to worry about being decrypted by others to obtain the original information.


Summary: How to set a password to be safe

  • Do not use too common passwords, and do not use common passwords similar to 123456.
  • Each application software password is recommended to be different, to avoid one application database being taken off the database, and all application passwords will collapse.
  • You can increase the registration time, registration location, application features and other methods when setting the password. For example, tianjin123456 represents the application registered in Tianjin.

Guess you like

Origin blog.csdn.net/qq_44273429/article/details/108331618