2015-04-07 13:47:39 +08:00
|
|
|
#coding=utf-8
|
|
|
|
|
|
|
|
module Trustie
|
|
|
|
module Utils
|
|
|
|
def self.digest(diskfile)
|
|
|
|
md5 = Digest::MD5.new
|
|
|
|
File.open(diskfile, "rb") do |f|
|
|
|
|
buffer = ""
|
|
|
|
while (buffer = f.read(8192))
|
|
|
|
md5.update(buffer)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
md5.hexdigest
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
if __FILE__ == $0
|
|
|
|
puts Trustie::Utils.digest('/Users/guange/Downloads/QQ_V4.0.2.dmg')
|
2015-05-08 14:28:17 +08:00
|
|
|
end
|