Groovy web console

subscribe to the feed Subscribe
to this
site
Groovy Base64 (via #groovywebconsole)
tweet this snippet Tweet
this
script

Groovy Base64

Published 6 months ago by Leo with tags Groovy Base64
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
def s = ''

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

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