Created
August 23, 2010 23:54
-
-
Save thisivan/546593 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Hex digest a file, without loading the whole file into memory: | |
require 'digest/md5' | |
def md5sum_file(path) | |
digest = Digest::MD5.new | |
File.open(path, 'r') do |file| | |
while buffer = file.read(1024*8) | |
digest << buffer | |
end | |
end | |
digest.hexdigest | |
end | |
puts md5sum_file('/etc/hosts') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment