Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

On Mac OSX Leopard PowerPC, if I do:

echo "hello" | md5 
on the command line, the result is:
b1946ac92492d2347c6235b4d2611184
But if I enter hello into one of the online md5 hash sites like http://md5online.net/, I get:
5d41402abc4b2a76b9719d911017c592
Am I doing something wrong? If I want to use md5 on the go, how can I make sure what I'm getting on the command line will agree with the online md5 tools? Thanks.

share|improve this question
    
Works for me on Windows with Total Commander creating the MD5 checksum. Same as the online version. – Snark Nov 17 '09 at 8:04
    
Thanks, Snark. Rudedog solved the problem when using md5 on the command line, at least for POSIX systems. Give him a +1 if you can. I'm too new. – pellea72 Nov 17 '09 at 8:13
    
+1 for Rudedog! :-) – Snark Nov 17 '09 at 8:16
up vote 27 down vote accepted

When you echo from the command line, md5 is calculating the sum of 6 characters - h,e,l,l,o plus newline. The text you enter in a website doesn't have a newline.

Try doing

echo -n hello | md5

and it'll give you what you expect. The -n tells echo not to output a newline.

share|improve this answer
    
Oops. I didn't notice the '-n' tag. You're right Rudedog. That worked. Thanks. – pellea72 Nov 17 '09 at 8:11

b1946ac92492d2347c6235b4d2611184 ist the md5 of just the string

hello

5d41402abc4b2a76b9719d911017c592 ist the md5 of

hello

CR+LF

CR+LF is the Windows newline.

share|improve this answer

you can also use printf instead of echo, which automatically suppresses the newline character.

printf hello | md5

or even

printf "hello" | md5

I know I am two years late, but still ... could be a useful information for someone (like me) coming here via Google search :)

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .