An MD5 is a type of Hash, also, a Checksum.
An MD5 hash is a one way verification sum which can be used to verify a string or contents of a file. Once you have a file and an MD5 checksum, the recipient of the file can also perform an MD5 calculation to ensure that the file’s contents are unchanged. They may have been changed maliciously such as in the case of a binary file, or simply by data corruption. An MD5 is NOT a type of encryption. It can not be reversed.
We can use PHP to do the following:
< ?php $string = “teststring”; $checksum = md5($string); echo “The checksum is: ” . $checksum . “\n”; ?>
The output is:
The checksum is: d67c5cbf5b01c9f91932e3b8def5e5f8
We can use the ‘md5sum’ linux command and pipe input to it via STDIN.
test:~# echo “teststring”|md5sum
Why is the output of this md5sum different to that above? Well, ‘echo’ automatically adds a newline to the string to make it “teststring\n”. We can surpress this with -n:
test:~# echo -n “teststring”|md5sum
We can also run the md5sum command against a file:
test:~# md5sum /bin/bash