21 lines
382 B
21 lines
382 B
6 years ago
|
#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')
|
||
|
end
|