First, Introduction
Message digest can generate a fixed length (16 or 20 bytes) of information summary for any length of message, based on a one-way hash function, the message digest cannot be recovered from the original text, so it is safe; the source text and message digest is one by one corresponding, so it is called a fingerprint.
Second, the grammar
OpenSSL Dgst[-md5|-md4|-md2|-sha1|-sha|-mdc2|-ripemd160|-dss1] [-c] [-d] [-hex] [-binary] [-out filename] [-sign FileName] [-keyform arg] [-passin arg] [-verify filename] [-prverify filename] [-signature filename] [-hmac key] [file ...]
Options
-c to output the digest with separating colons-R to output the digestinchcoreutils Format-D to Output debugInfo-hex Output as hex dump-binary outputinchbinary Form-signfileSign Digest using private keyinch file-verifyfileVerify a signature using public keyinch file-prverifyfileVerify a signature using private keyinch file-keyform Arg keyfileformat (PEM or ENGINE)-Out filename output to filename rather than stdout-signaturefilesignature to verify-sigopt nm:v Signature parameter-HMAC key Create hashed MAC with key-mac algorithm Create MAC (not neccessarily HMAC)-macopt nm:v MAC algorithm parameters or key-engine e Use engine E, possibly a hardware device.-MD4 to use the MD4 message digest algorithm-MD5 to use the MD5 message digest algorithm-ripemd160 to use the ripemd160 message digest algorithm-Sha to use the SHA message digest algorithm-SHA1 to use the SHA1 message digest algorithm-sha224 to use the sha224 message digest algorithm-SHA256 to use the sha256 message digest algorithm-sha384 to use the sha384 message digest algorithm-sha512 to use the sha512 message digest algorithm-whirlpool to use the Whirlpool message digest algorithm
Third, examples
1. Message Digest of the file
OpenSSL dgst-md5 Test.txt
2. Sign the message digest with the private key and check it with the public key
OpenSSL dgst-md5-sign Prikey.pem-outsign.binary test.txt -md5-verify pubkey.pem-signature sign.binary t Est.txt
3. Message Authentication Code
" 123456 " test.txt
Reference: http://blog.csdn.net/fym0121/article/details/7982620
Openssl dgst Command