2 # -*- encoding: binary -*-
4 # Reads from stdin and outputs the SHA1 hex digest of the input this is
5 # ONLY used as a last resort, our test code will try to use sha1sum(1),
6 # openssl(1), or gsha1sum(1) before falling back to using this. We try
7 # all options first because we have a strong and healthy distrust of our
8 # Ruby abilities in general, and *especially* when it comes to
9 # understanding (and trusting the implementation of) Ruby 1.9 encoding.
12 $stdout.sync = $stderr.sync = true
16 digest = Digest::SHA1.new
17 if buf = $stdin.read(bs)
20 end while $stdin.read(bs, buf)
23 $stdout.syswrite("#{digest.hexdigest}\n")