msgbartop
I will happily conduct a FREE basic web security scan for any genuine organization interested in my services to point out whether or not I can find vulnerabilities in your application. Just contact me.
Need a PHP Programmer, PHP staff or project manager? Contact me now.
msgbarbottom

01 Apr 09 Creating an MD5 on Linux with md5sum

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.

In the case that you know the length of the data, say between 5 and 8 characters for a password, you can attempt to brute force (try every combination automatically until something hits) the password. For that reason passwords are often salted before being MD5′d however salts and their purpose are outside the scope of this article.

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 also use the ‘md5sum’ linux command and pipe input to it via STDIN.

echo “teststring”|md5sum

test:~# echo “teststring”|md5sum
50be80a7a199c13e2bb09e2e745ba233  -

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
d67c5cbf5b01c9f91932e3b8def5e5f8  -

We can also run the md5sum command against a file:

test:~# md5sum /bin/bash
c8770eb0a3f2b6088914b4bc29301113  /bin/bash

Tags: , , ,



Reader's Comments

  1. |

    thanks for the info…

    you fix my headache… :)

  2. |

    [...] will happen now, is that when a query is provided, we take the MD5 sum of that query. We then check to see if we have that query response in memcache already. If so, [...]



Leave a Comment

You must be logged in to post a comment.