Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Current »

Description

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.

Code

Paste the below into a file "sha1.groovy" and run with a file param, i.e.:

Calling the script

and now for the code:

Script Code

Author: Matias Bjarland, Iteego Inc

  • No labels