Skip to content

Instantly share code, notes, and snippets.

@bitsnaps
Forked from mujahidk/base64coding.groovy
Created September 24, 2022 09:45
Show Gist options
  • Save bitsnaps/ddd71003b741a7f948f14cb76c25d4b5 to your computer and use it in GitHub Desktop.
Save bitsnaps/ddd71003b741a7f948f14cb76c25d4b5 to your computer and use it in GitHub Desktop.
Base64 encoding and decoding in Groovy.
def text = "Going to convert this to Base64 encoding!"
// Encode
def encoded = text.bytes.encodeBase64().toString()
println encoded
// Decode
byte[] decoded = encoded.decodeBase64()
println new String(decoded)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment