MD5 is a popular hash function used in computing for two primary reasons:-
One of the fundamental rules of security is not to store passwords in plaintext. The question one might ask then, is how to verify that the user has entered the correct password. Well, you can either encrypt or hash the password before storing it in the database. The difference between encryption and hashing is that the former is reversible while the latter is a one way operation. Unless you need to store password for an external application such as database, you should always choose hashing over encryption.
The password that the user provides at the time of login should be hashed on the server side and then compared against the previously stored hash in the database. One of the key properties of any hash function is that everytime a value is hashed it will always yield the same result. So, you can rest assured that even though you are comparing hashes, the user will only be able to login by providing the correct password. Actually, that is not 100% correct. There is an extremely small chance that two different values might generate the same hash. This means a user might be able to login with a wrong password. But, the chance of this happening is so low that you can totally forget about it. This is another property of a good hash function – collisions should be rare.
As computer processors become faster, MD5 becomes weaker and weaker. Designed in 1991, MD5 hash is no longer fit to be used as a hashing mechanism for passwords. These days, bcrypt is recommended as a password hash function as it is much slower than MD5, SHA-1 and even SHA-2. So, brute forcing bcrypt is extremely difficult.
Verifying Integrity of Files
Because of the fact that MD5 is a hash function and a fast one, it is extremely suited for verification of integrity of data or files. Say you have downloaded a file from the internet. How do you know that it did not get corrupted while downloading? Perhaps the file got corrupted while residing on your disk. MD5 hashes really come handy here. You can run your file through an MD5 Calculator which reads the entire file and generates the MD5 hash. The hash itself is of a fixed size, 128-bit. So, no matter how big your file is, the MD5 hash is always of the same length. It looks something like this
61634d80b55156c331d70ce370f1d028 in it’s human readable hex form. Once you get the MD5 hash of your file, you can compare it against the MD5 listed for your file on the source website. Most websites list the MD5 checksum of binary files that they allow to be downloaded. If the two hashes match you know that your file is intact.