Groovy web console

subscribe to the feed Subscribe
to this

Base64 encoding/decoding

Published 1 decade ago by mrhaki with tags string base64 encode decode
Actions Execute script  ▶ Edit in console Back to console Show/hide line numbers View recent scripts
def s = 'Argh, Groovy you say, mate?'

String encoded = s.bytes.encodeBase64().toString()
assert 'QXJnaCwgR3Jvb3Z5IHlvdSBzYXksIG1hdGU/' == encoded

byte[] decoded = encoded.decodeBase64()
assert s == new String(decoded)