Is the md5sum linux command working correctly?

According to Wikipedia, the empty line md5 sum is d41d8cd98f00b204e9800998ecf8427e

I confirmed this with my md5 library

However, when I run

echo "" | md5sum 

in my linux shell, I get 68b329da9893e34099c7d8ad5cb9c940 -

In fact, none of my hashes match the output of the md5sum command.

Any thoughts on this mismatch?

+2
linux shell md5
source share
4 answers

With this command, you compute md5sum a single newline character. Try instead:

 echo -n "" | md5sum 
+12
source share

You must delete the new line in which the echo creates

 $ echo -n '' | md5 d41d8cd98f00b204e9800998ecf8427e 
+6
source share

Try:

 echo -n | md5sum 

Without "-n", the echo prints a new line, which md5sum properly processes.

+5
source share

use more portable printf

 printf "" | md5sum 
+2
source share

All Articles