【You are great】A brief introduction to the MD5 algorithm_Is MD5 an encryption algorithm?

A programmer may encounter various algorithms in his life, but there are always a few algorithms that a programmer will definitely encounter and need to master with a high probability. Let’s talk about a common algorithm today~

Topic template:

(Reminder: Please delete unnecessary content before publishing your work.)

I. Introduction

MD5 is a very commonly used algorithm in program development, and many people have used it. One of the most commonly used scenarios of the MD5 algorithm is user registration, and the password is encrypted with MD5. The password cannot be reversely decrypted to improve security. But is MD5 really encryption? What exactly do you mean by encryption?

Two: MD5 algorithm introduction

MD5 is just a hash algorithm, not a real encryption algorithm

Three: What is the MD5 algorithm?

So the question is, what is encryption?

What is encryption?
  • Encryption means that after the data is converted, the data becomes another format, and no one can convert the data back except the person who has the decryption method.
  • The purpose of the encryption algorithm is that others cannot successfully view the encrypted data, and the data can be decrypted to re-view the data when needed.

Therefore, encryption is commonly used for network communications. Because anyone can get the communication data on the network, encrypt the data before sending it, and after it is delivered, the other party will decrypt it and then check it, which can prevent peeping on the network. For example, HTTPS, which everyone knows is "safe" but few people know "why it is safe", is the network security guaranteed by encryption algorithm. 

Four: hash algorithm

Hash algorithm , that is, hash, also known as hash algorithm, is a general term for algorithms that convert arbitrary data into fixed-length (or limited-length) data

For example, my name is Zhang San and your name is Li Si, then the algorithm of "person -> name" is called a hash algorithm

Hash algorithms are usually used to make digital fingerprints, which means "you see this thing as if you saw the original data"

For example: when we download a large file from some websites, the website provides us with the MD5 or SHA1 code to verify the integrity of the file, which is the hash value of the original file

Five: The relationship between MD5 and hash

There are many hash algorithms, MD5 is one of them, this is MD5. Therefore, an excellent hash algorithm usually needs to have a low collision probability (that is, the hash values ​​​​of different data are usually different)

irreversible encryption

The MD5 algorithm is a hash algorithm. The design goal of the hash algorithm is determined by itself. It is irreversible most of the time, that is, the data you get through the hash algorithm cannot be restored by any algorithm. Therefore, since the data cannot be restored, it cannot be called decryptable; since it cannot be decrypted, the hashing process cannot be called "encryption".

in conclusion

MD5 is just a hash algorithm, not a real encryption algorithm

extension

In our daily development, we come into contact with various encryption algorithms, which can be simply divided into

Symmetric encryption algorithm: The encryption algorithm is the same as the secret key of the decryption algorithm.
Asymmetric encryption algorithm: The keys of the encryption algorithm and the decryption algorithm are inconsistent.
Hash Algorithm: Without a secret key, it is currently impossible to reverse decrypt. (except brute force)
General encryption algorithm:
  • DES encryption algorithm,
  • AES encryption algorithm,
  • RSA encryption algorithm,
  • Base64 encryption algorithm,
  • XXXTEA encryption algorithm, etc.

Among them, MD5 and SHA-1 are both hash and hash algorithms, and strictly speaking, they are not encryption algorithms.

Guess you like

Origin blog.csdn.net/wangwei490202517/article/details/131721263