tests: just use the sha1sum implemented in Ruby
[unicorn.git] / t / bin / sha1sum.rb
blob53d68ce4a03e63b47170127246f85507b7d508cc
1 #!/usr/bin/env ruby
2 # -*- encoding: binary -*-
3 # Reads from stdin and outputs the SHA1 hex digest of the input
5 require 'digest/sha1'
6 $stdout.sync = $stderr.sync = true
7 $stdout.binmode
8 $stdin.binmode
9 bs = 16384
10 digest = Digest::SHA1.new
11 if buf = $stdin.read(bs)
12   begin
13     digest.update(buf)
14   end while $stdin.read(bs, buf)
15 end
17 $stdout.syswrite("#{digest.hexdigest}\n")