Skip to content

Instantly share code, notes, and snippets.

@kshep92
Forked from ikarius/md5.groovy
Created February 24, 2017 02:52
Show Gist options
  • Save kshep92/92f0864cc9a4c1a0bf380890a2a899f0 to your computer and use it in GitHub Desktop.
Save kshep92/92f0864cc9a4c1a0bf380890a2a899f0 to your computer and use it in GitHub Desktop.
How to generate a MD5 hash in Groovy ...
import java.security.MessageDigest
String fileContents = "<html><head></head><body>Hello world!</body></html>"
MessageDigest sha = MessageDigest.getInstance("MD5")
byte[] digest = sha.digest(fileContents.bytes)
print "${digest.encodeHex()}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment