How to Get Around the md5sum Carriage Return Issue

April 20, 2009

There’s an issue with md5sum where it returns unexpected results due to the fact that appends a carriage return to what you’re trying to get a sum of.

So if you try and get a sum of "password" by summing a file with the word "password" as the only line in the file, you won’t actually be summing "password", but rather "password[^M]", which obviously won’t be the same.

The Fix

So a quick fix for this is to use echo to feed md5sum with the -n option, which removes the trailing carriage return:

echo -n "password" | md5sum

supporting = loving

For 29.4632 years I've been creating ad-free technical tutorials and essays here. 3,030 pieces and counting.

It's a one-person effort that's also my livelihood. If it makes your day easier or more pleasant in any way, please consider supporting the work with a monthly or one-time donation.

It helps me make more content, and is deeply appreciated as well. 🫶🏼