MD5 is a frequently used one-way hash algorithm, it is commonly used in following situations:
- Check data integrity. We take hash of the data stored in two different places and compare them. If the hash results are the same, then there is no need to check the actual data. This utilizes the collision-resistant feature. Two different data block will have little chance that their hash values will be the same. Many data service providers use such technique to check repeated data to avoild repeating uploading. Also, it is frequently used in transferring file to ensure the file is not modified during the transmission.
- Store user password. Storing the hashed password into the database. Since it's an one-way alogrothm, you cannot decrypt the hashed value to the plain text, so even the database is accessed by unauthorized people, they cannot get the users password.
But now MD5 is not suitable to be used in above situations anymore.
The first use : the biggest problem of the first use is there are many collisions happening in real life. For example, the two data block below have exactkly the same MD5 hash value.
Data block 1
4d c9 68 ff 0e e3 5c 20 95 72 d4 77 7b 72 15 87
d3 6f a7 b2 1b dc 56 b7 4a 3d c0 78 3e 7b 95 18
af bf a2 00 a8 28 4b f3 6e 8e 4b 55 b3 5f 42 75
93 d8 49 67 6d a0 d1 55 5d 83 60 fb 5f 07 fe a2
Data block 2
4d c9 68 ff 0e e3 5c 20 95 72 d4 77 7b 72 15 87
d3 6f a7 b2 1b dc 56 b7 4a 3d c0 78 3e 7b 95 18
af bf a2 02 a8 28 4b f3 6e 8e 4b 55 b3 5f 42 75
93 d8 49 67 6d a0 d1 d5 5d 83 60 fb 5f 07 fe a2
The same MD5 value
008ee33a9d58b51cfeb425b0959121c9
This means if the user provides data block 1 and the server has stored data block 2, then the server will copy the data block 2 to the user's space who want to store data block 1. The consequence is that the user's data is lost.
The second use : it is easy to be attacked with rainbow table, a precomputed table for reversing cryptographic hash functions, it has no much difference with storing password in plain text.
So find a better hash algorithm when you want to ensure your data security.
Reference : http://blog.jianguoyun.com/?p=481