Created
March 17, 2014 06:31
-
-
Save dagezi/9594839 to your computer and use it in GitHub Desktop.
Calculate SHA1 hash on gradle.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// file must be File object. | |
def calcSha1(file) | |
{ | |
MessageDigest md = MessageDigest.getInstance("SHA-1"); | |
file.eachByte 4096, {bytes, size -> | |
md.update(bytes, 0, size); | |
} | |
return md.digest().collect {String.format "%02x", it}.join(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for the useful gist! With Groovy 1.8.6 and later, line 8 can be simplified to: