Create An MD5 Hash Of A Text String
From RZWiki
To create an MD5 hash (aka digest or checksum) of a text string on Linux platforms, you'll need to combine two commands in one of two ways, as follows;
echo -n text_string | openssl dgst -md5
Usage Examples
echo -n text_string | md5sum
0e7d8b2122772a0c30c762d7bc06dd43 -
The - part of the output simply indicates the input was standard input rather than a file.
echo -n text_string | openssl dgst -md5
0e7d8b2122772a0c30c762d7bc06dd43
Usage Notes
The hash will change if the case of any part of the text string changes; in other words, the input is case sensitive.
The -n option prevents the echo command default behaviour of outputting a trailing newline, which would become part of the input to the sha1sum or dgst commands and result in an incorrect hash/digest being generated.
Why the two commands don't directly support text string input I don't know.
To generate SHA1 hashes/digests, you can replace the md5sum command with the sha1sum command
To generate MD2, MD4, SHA, SHA1, SHA256, SHA512, MDC2 or RIPEMD160 hashes/digests using the OpenSSL dgst command simply replace the -md5 option with the appropriate algorithm name, as listed here.
Related Articles
Other articles in our How To... section
Information on other Linux commands
Information on F5 BigIP commands
Information on Cisco commands
Information on Vyatta commands
Information on Extreme commands
Information on Zebra commands
Information on Secure Platform commands
Information on Blue Coat SGOS commands
Information on Nokia IPSO commands
(replacing the # with an @) |






