Created
June 2, 2016 21:10
-
-
Save starkcoffee/a8fbea118937f5af9c431c6b5d62e06f to your computer and use it in GitHub Desktop.
Base64 encoding and back in scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"prove encoding is a thing" in new Context { | |
val originalStr = "tschüß" | |
val base64EncodedStr = Base64.getEncoder.encodeToString(originalStr.getBytes("UTF-8")) | |
val decodedStr = new String(Base64.getDecoder().decode(base64EncodedStr), "ASCII") | |
decodedStr ==== originalStr | |
} |
Author
starkcoffee
commented
Jun 2, 2016
Of cause this won't work, it is encoding as UTF-8 and decoding using ASCII.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment