Skip to content

Instantly share code, notes, and snippets.

@aslakhellesoy
Created December 14, 2008 14:22
Show Gist options
  • Save aslakhellesoy/35695 to your computer and use it in GitHub Desktop.
Save aslakhellesoy/35695 to your computer and use it in GitHub Desktop.
# Usage:
# ruby sha1sum.rb FILE
#
# Compare results with http://en.wikipedia.org/wiki/Sha1sum
# http://lists.gnupg.org/pipermail/gnupg-announce/2004q4/000184.html (Windows)
require 'digest/sha1'
hashfunc = Digest::SHA1.new
open(ARGV[0], "rb") do |io|
while(!io.eof)
hashfunc.update(io.readpartial(1024))
end
end
puts hashfunc.hexdigest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment