Skip to content

Instantly share code, notes, and snippets.

@ikarius
Created February 9, 2010 09:57
Show Gist options
  • Save ikarius/299062 to your computer and use it in GitHub Desktop.
Save ikarius/299062 to your computer and use it in GitHub Desktop.
How to generate a MD5 hash in Groovy ...
def generateMD5(String s) {
MessageDigest digest = MessageDigest.getInstance("MD5")
digest.update(s.bytes);
new BigInteger(1, digest.digest()).toString(16).padLeft(32, '0')
}
@diroussel
Copy link

In Groovy 2.5 you can just do:

'Hello'.md5()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment