Mac OS X: How to verify a Hash digest?

Mac OS 內建了一些校驗文字或檔案 Hash 值的指令,不過我常用的只有 md5。這天需要用 SHA1 的時候一整個想不起來要用什麼指令… XD

來彙整一下這些指令好了…

先從基本的 md5 開始。

計算檔案的 md5:

$ md5 example.jpg
MD5 (example.jpg) = e9f598ee0208e6757dc583303a05847a

計算字串的 md5:

$ md5 -s "password"
MD5 ("password") = 5f4dcc3b5aa765d61d8327deb882cf99

計算檔案的 sha1:

$ shasum example.jpg
61350660b5c4554d846cca893c09eb05e61cb223  example.jpg

其他雜湊公式:

$ openssl sha1 --help

 


Posted

in

by

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *