How to Get Around the md5sum Carriage Return Issue
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.
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