Skip to content

Instantly share code, notes, and snippets.

View mcquinne's full-sized avatar

Evan McQuinn mcquinne

  • CIRES + NCEI
  • Denver, CO
View GitHub Profile
@mcquinne
mcquinne / md5.groovy
Created May 10, 2012 20:46 — forked from ikarius/md5.groovy
Generate MD5 hash of a file while being as Groovy as possible.
def generateMD5( File file ) {
def digest = java.security.MessageDigest.getInstance("MD5")
file.eachByte( 4096 ) { buffer, length ->
digest.update( buffer, 0, length )
}
new BigInteger(1, digest.digest()).toString(16).padLeft(32, '0')
}