How can you create an md5 hash for a string on a mac using bash? md5sum does not exist in my environment. I did a man for md5 but I’m confused about what that really does.
md5 "string"
does not return a hash.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This should work –
or if you prefer
here stringnotation then –UPDATE:
Per the
manpage, you can play around with any of the following optionsNote: MD5 always produces the same hash. The reason you find the output different from the example given above is due to a point that has been made in the comments. The first two examples use the trailing
newlinecharacter to produce the hash. To avoid that, you can use:For example, if you use
echo -n "string" | md5(note the-noption), you getb45cffe084dd3d20d928bee85e7b0f21. But, if you useecho "string" | md5, you getb80fa55b1234f1935cea559d9efbc39a.Or, verify it with the shell: