As long as we're still on the subject of cryptography, I thought I would go into a little more detail on what MD5 is and how it can be used.
First it is important to understand what a hash is. A hash is a sort of fingerprint for computer data, and it is composed of a predetermined number of alphanumeric characters. You can determine a hash for any type of data (i.e. text, files like Word documents, images, etc.). A hash could look like this:
5eb63bbbe01eeed093cb22bb8f5acdc3So how do you find a hash? You have to run a mathematical algorithm on the data from which you would like a hash to be determined. When the algorithm is run, the data are processed with many different mathematical operations that are extremely difficult to undo, and a hash value is created. An algorithm will
always produce a hash of the same size
every time, no matter how much or how little data are used as input. Different algorithms produce different sized hashes. The example below demonstrates the hash values for two commonly used algorithms. It shows the hash value that was calculated when "Hello world" was the input and when "Hello world!" was the input.
MD5
Hello world: 3e25960a79dbc69b674cd4ec67a72c62
Hello world!:
86fb269d190d2c85f6e0468ceca42a20
SHA-1
Hello world:
7b502c3a1f48c8609ae212cdfb639dee39673f5e
Hello world!:
d3486ae9136e7856bc42212385ea797094475802
As you can see from the example, just adding "!" to the end of the input completely changed the hash values. This is important, because we want the hashes to be unpredictable. Also, the longer a hash is, the more secure it is.
So MD5 is an algorithm used to produce hash values. But how can it be used?
One use is to check file integrity after transfer. If you download a large file from the internet, there is a greater chance that some of the file did not transfer correctly, making the file corrupt. If the site you downloaded the file from provides an MD5 hash of the file, you could run the file through MD5 and see what hash value you get. If it matches the provided hash, your file is intact.
MD5 is also used for password storage. Instead of storing a user's password as plain text in a database, it is a better idea to hash it first. This way, anyone with access to the database cannot see all of the passwords. I actually implemented this last week on the
Tutoring System. The database stores the hash values of passwords instead of the actual password. When a user logs into the system, the password they entered is hashed using MD5 and then the hash value is compared to the value in the database.
On a final note, I thought that it was important to mention that MD5 is not as strong as some other hashes. Newer applications requiring a high level of security should use an algorithm like SHA-256.
Resources: