Openssl dgst命令

來源:互聯網
上載者:User

標籤:

一、簡介

訊息摘要可以對任意長度的訊息產生固定長度(16或20個位元組)的資訊摘要,理論基於單向HASH函數,根據訊息摘要無法恢複出原文,所以是安全的;訊息原文和訊息摘要是一一對應的,所以又被稱作指紋。

 

二、文法

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...]

選項

-c              to output the digest with separating colons-r              to output the digest in coreutils format-d              to output debug info-hex            output as hex dump-binary         output in binary form-sign   file    sign digest using private key in file-verify file    verify a signature using public key in file-prverify file  verify a signature using private key in file-keyform arg    key file format (PEM or ENGINE)-out filename   output to filename rather than stdout-signature file signature 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

 

三、執行個體

1、對檔案進行訊息摘要

openssl dgst -md5 test.txt

2、用私密金鑰對訊息摘要進行簽名,並用公開金鑰進行驗簽

openssl dgst -md5 -sign prikey.pem -out sign.binary test.txt     openssl dgst -md5 -verify pubkey.pem -signature sign.binary test.txt

3、訊息認證碼

openssl dgst -md5 -hmac "123456" test.txt

 

參考:http://blog.csdn.net/fym0121/article/details/7982620

Openssl dgst命令

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.