Ruby with MD5 and SHA1

require 'digest/md5'
require 'digest/sha1'


1. 字串
Digest::MD5.hexdigest("I LOVE NBA")
$>  "d5aca67f9417c8476a488283d2d64a47"

Digest::SHA1.hexdigest "I LOVE NBA"
$> "90cac378955fc7f3afd713b9ea8cab1c438b2283"

2. 檔案
Digest::MD5.hexdigest("/home/ham/test.py")
$> "fc76a29fb81a2dd22143ee37ff0d2809"

Digest::SHA1.hexdigest "/home/ham/test.py"
$> "08fcf94bc142b4118bb784f107aa9e161090b394"

留言

熱門文章