There are a number of posts on the net about SHA1 hashing in groovy but they tend to assume small data sets. This script calculates a SHA1 hash for an arbitrary size argument file using a one MB memory buffer.
Note that the script uses the File.eachByte(int, closure) method which is only available in Groovy v1.7.4 and later. You can naturally replace this construct with some other pattern, but as it fits so beautifully for the purpose, the script makes use of it.
Paste the below into a file "sha1.groovy" and run with a file param, i.e.:
and now for the code:
Author: Matias Bjarland, Iteego Inc