Ubuntu md5 sum checking for string input

Hello Everybody,

Today I got an interesting challenge – compare md5 hashes for the same string. One hash is generated at the server side and I had to compare it with hash, generated locally.

For example, lets take this string: “Hello World, md5sum!”.
Checking on the site: http://www.miraclesalad.com/webtools/md5.php
Got hash: 984c8704bb59913ae30addd189703dd0

Opening terminal in my Ubuntu 11.04, type:
~$echo Hello World, md5sum! | md5sum
But getting frustrating result: 24a67d0c7b0144bd942df5ebfdf03e09

What is wrong? Who knows? 🙂

Yep, trailing new line is the issue:
From man echo:
-n do not output the trailing newline

Trying again:
echo -n Hello World, md5sum! | md5sum
984c8704bb59913ae30addd189703dd0 –

Hashes are the same:
1) 984c8704bb59913ae30addd189703dd0
2) 984c8704bb59913ae30addd189703dd0

Happy hashing! (:

Best regards,
Yahor