OpenSSL下hash函數

來源:互聯網
上載者:User

OpenSSL下hash函數

OpenSSL下hash函數:是無法復原的函數,它的輸入可以是任意長度的位元組流。它的輸出是固定大小的,hash函數的作用就是給你的檔案產生一個摘要,它是獨一無二的。

OpenSSL TLS心跳讀遠程資訊泄露漏洞 (CVE-2014-0160)

OpenSSL嚴重bug允許攻擊者讀取64k記憶體,Debian半小時修複

OpenSSL “heartbleed” 的安全性漏洞

通過OpenSSL提供FTP+SSL/TLS認證功能,並實現安全資料轉送
 
例如:y=f(x) x代表輸入  y代表輸出  輸入x求y容易  單輸入y求x就難了
 
我們常見的hash函數MD5和SHA1 當然和有其他的比較少見。
 
DM5 :通常為128個bits  16個位元組
 
sha1:通常為160bits    一個位元組8個bits  20個位元組
 
[root@RedHat ~]# md5sum /etc/passwd    //linux下也有命令來求檔案md5的值
c79a0c2c792891374595009e6155435c  /etc/passwd
 

[root@redhat ~]# openssl dgst -md5 /etc/passwd
MD5(/etc/passwd)= c79a0c2c792891374595009e6155435c
 
[root@redhat ~]# openssl dgst -sha1 /etc/passwd
SHA1(/etc/passwd)= b4e99419a91a3908e5e5c9c07a0d91c408c1a008
 
[root@redhat ~]# sha1sum /etc/passwd
b4e99419a91a3908e5e5c9c07a0d91c408c1a008  /etc/passwd
 
-c 參數 給輸出的hash值以:隔開
 
[root@redhat ~]# openssl  dgst -sha1 -c /etc/passwd
SHA1(/etc/passwd)= b4:e9:94:19:a9:1a:39:08:e5:e5:c9:c0:7a:0d:91:c4:08:c1:a0:08
 
同樣也可以使用md5校正檔案的完整性,檔案的一個位元組變了,hash值就會發生天翻地覆的變化。
 
通常一些官方的網站把軟體包發布時都會發布MD5和sha1值,防止別人篡改軟體包。
 
[root@redhat opt]# cat txt
hello world!
[root@redhat opt]# md5sum txt
c897d1410af8f2c74fba11b1db511e9e  txt
 
[root@redhat opt]# cat txt
hollo world!
[root@redhat opt]# md5sum txt
ada39606d10543a059d139d1debb6a37  txt

OpenSSL 的詳細介紹:請點這裡
OpenSSL 的:請點這裡

本文永久更新連結地址:

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.