Skip to content

Instantly share code, notes, and snippets.

@ravenberg
Created August 2, 2016 06:45
Show Gist options
  • Save ravenberg/a94ca4faee9f2b45c82eaa6b4b3ddcd9 to your computer and use it in GitHub Desktop.
Save ravenberg/a94ca4faee9f2b45c82eaa6b4b3ddcd9 to your computer and use it in GitHub Desktop.
def get_hash(name)
readsize = 64 * 1024
File.open(name, 'rb') do |f|
size = File.size?(name)
data = f.read(readsize)
f.seek(-readsize, IO::SEEK_END)
data += f.read(readsize)
return Digest::MD5.hexdigest(data)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment