background

Some time ago, I had an interview with Ali. He asked me a lot about symmetric encryption, asymmetric encryption, digital certificates, digital signatures and other concepts. The answer is not very good because the applications at work are not exposed to that much. I went back and combed it out.

One day I was working in the user login scenario in order to ensure that the password was not transmitted in clear text. A colleague at the front end told me, and the project management also told me that the front end would use MD5 encryption and pass it to your login interface.

And I thought, how do I get it and how do I decrypt it? I’ll just tell them that MD5 is irreversible. So I think it is necessary to give them a clear usage scenario of MD5.

By the way, there’s a website on the Internet, which I’m sure many of you have used

Please note that the instructions in red make it clear that cracking is a matter of brute force, massive amounts of data. Not the decryption process. It’s a process of brute force. So again, MD5 is irreversible.

So what exactly is MD5

MD5: A hash algorithm

Essentially, MD5 is just a hash algorithm.

Hash algorithm, also known as hash algorithm, is a class of arbitrary data into fixed length (or limited length) data algorithms collectively. For example, if I call Zhang SAN and you call Li Si, then the algorithm of “person -> name” is called a hash algorithm. A hash algorithm is often used to create a digital fingerprint, which means “you see it as if it were the original data.” For example, when we download a large file from a website, we are provided with an MD5 or SHA1 code to verify the integrity of the file, which is the hash value of the original file. There are many kinds of hashing algorithms, MD5 is one of them, this is MD5. Therefore, a good hash algorithm usually needs to have a low collision probability (that is, the hash value of different data is often different).

What is encryption?

Encryption is when the data is converted into a different format, and no one can convert it back except the person who got the decryption method. Therefore, encryption is commonly used for network communication. Because of the communication data on the network, anyone can get it, encrypt the data and then send it, and decrypt it and then check it, so as to prevent peeping on the network. For example, HTTPS, which everyone knows is “safe” but few know “why”, is a network security guaranteed by encryption algorithms.

So, is MD5 encryption?

Encryption algorithms are designed so that encrypted data cannot be viewed successfully by others and can be decrypted to re-view the data if necessary. The MD5 algorithm is a hash algorithm, and the design goal of the hash algorithm itself determines that it is irreversible in most of the time, that is, the data obtained by the hash algorithm cannot be restored by any algorithm. Therefore, since the data can not be restored, it can not be called decryption; Since it cannot be decrypted, the process of hashing cannot be called “encryption”.

MD5 Application Scenarios

The most scenario we have come into contact with, is to download the file when there is an MD5 digest information attached, this MD5 digest information, is to verify that the file in the network transmission process, not back tampered. Therefore, MD5 is more suitable for checking the transmitted data.