Skip to content

Instantly share code, notes, and snippets.

@kanemu
Created October 10, 2010 07:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kanemu/619064 to your computer and use it in GitHub Desktop.
Save kanemu/619064 to your computer and use it in GitHub Desktop.
[groovy]100本斬りお題82
// g100pon #82 Base64 エンコード/デコード
//エンコード
String str = '我輩は猫である。名前はまだ無い。'
def bs64str = str.getBytes().encodeBase64().toString()
assert bs64str == '5oiR6Lyp44Gv54yr44Gn44GC44KL44CC5ZCN5YmN44Gv44G+44Gg54Sh44GE44CC'
//デコード
String str2 = new String(bs64str.decodeBase64())
assert str2 == str
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment