On a Mac OS X v10.5 (Leopard) PowerPC, if I do:

echo "hello" | md5 
on the command line, the result is:


But if I enter hello into one of the online MD5 hash sites like http://md5online.net/, I get:


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?

  • Works for me on Windows with Total Commander creating the MD5 checksum. Same as the online version.
    – Snark
    Nov 17, 2009 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, 2009 at 8:13

4 Answers 4


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.

  • Oops. I didn't notice the '-n' tag. You're right Rudedog. That worked. Thanks.
    – pellea72
    Nov 17, 2009 at 8:11
  • Thanks @Rudedog your answer from 12 years ago just saved my sanity!
    – Bill Gale
    Mar 25, 2021 at 0:06

You can also use printf instead of echo, which automatically suppresses the newline character:

printf hello | md5

Or even:

printf "hello" | md5

b1946ac92492d2347c6235b4d2611184 ist the md5 of just the string


5d41402abc4b2a76b9719d911017c592 ist the md5 of



CR+LF is the Windows newline.

  • -1. Totally mixed up. Sole hello gives 5d…; helloLF gives b1…; helloCRLF gives af5597c29467a96523a70787c319f4db. Feb 2, 2022 at 17:14

Depends on how you call (OSx), bash and zsh add newline character by default.

echo "123" | md5


echo "123" | tr -d "\n" | md5        


echo -n "123" | md5           


printf "123" | md5


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.