Skip to content

Instantly share code, notes, and snippets.

@timyates
Created February 23, 2012 11:23
Show Gist options
  • Save timyates/1892446 to your computer and use it in GitHub Desktop.
Save timyates/1892446 to your computer and use it in GitHub Desktop.
What's new in Groovy 1.8.6 -- byte[].encodeHex
String input = 'Groovy Base64 Encode'
String encoded = input.bytes.encodeBase64()
assert encoded == 'R3Jvb3Z5IEJhc2U2NCBFbmNvZGU='
byte[] decoded = encoded.decodeBase64()
assert input == new String( decoded )
String input = 'Groovy Hex Encode'
String encoded = input.bytes.encodeHex()
assert encoded == '47726f6f76792048657820456e636f6465'
byte[] decoded = encoded.decodeHex()
assert input == new String( decoded )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment