Groovy web console

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

Groovy Base64

Published 1 year 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