Created
February 9, 2010 09:57
-
-
Save ikarius/299062 to your computer and use it in GitHub Desktop.
How to generate a MD5 hash in Groovy ...
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
def generateMD5(String s) { | |
MessageDigest digest = MessageDigest.getInstance("MD5") | |
digest.update(s.bytes); | |
new BigInteger(1, digest.digest()).toString(16).padLeft(32, '0') | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In Groovy 2.5 you can just do: