Log in Go to the main page Page Discussion History Go to the file list Go to the site toolbox Bookmark and Share

Create An MD5 Hash Of A Text String

From RZWiki


Image:linux-logo-large.png

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 | md5sum

echo -n text_string | openssl dgst -md5

Image:Vm-power-on-medium.png 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

Image:accessories-text-editor-v2-medium.png 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.

Image:icemon-medium.png Related Articles

Other articles in our How To... section

Information on other Linux commands Image:linux-logo-small.png

Information on F5 BigIP commands Image:F5-logo-small.png

Information on Cisco commands Image:Cisco-logo-small.png

Information on Vyatta commands Image:Vyatta-logo-small.png

Information on Extreme commands Image:Extreme-logo-small.png

Information on Zebra commands

Information on Secure Platform commands

Information on Blue Coat SGOS commands

Information on Nokia IPSO commands


Image:internet-group-chat-small.png We really do appreciate all feedback so please do send your comments, suggestions or corrections to sjiveson#routerzone.eu
(replacing the # with an @)


Site Toolbox:

Personal tools
This page was last modified on 29 September 2009, at 09:40. - Disclaimers - About RZWiki
Powered by MediaWiki