Skip to content

Instantly share code, notes, and snippets.

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 bjing/f7c54ba35b56f5bcbd60a4f95bbf4aab to your computer and use it in GitHub Desktop.
Save bjing/f7c54ba35b56f5bcbd60a4f95bbf4aab to your computer and use it in GitHub Desktop.
Scala - Base64 encode/decode
// Base64 encode
val text = "This is plaintext."
val bytesEncoded = java.util.Base64.getEncoder.encode(text.getBytes())
// Base64 decode
val textDecoded = new String(java.util.Base64.getDecoder.decode(bytesEncoded))
println(textDecoded)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment