Last active
August 29, 2015 14:23
-
-
Save luctrudeau/dd20e7b35efe60efa608 to your computer and use it in GitHub Desktop.
Android Base64 Example
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
byte[] octets = "ETS".getBytes("UTF-8"); | |
String base64 = Base64.encodeToString(octets, Base64.URL_SAFE); | |
byte[] octets = Base64.decode(base64, Base64.URL_SAFE); | |
String text = new String(octets, "UTF-8"); |
Added URL_SAFE
Encoder/decoder flag bit to indicate using the "URL and filename safe" variant of Base64 (see RFC 3548 section 4) where - and _ are used in place of + and /.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Inspired from http://stackoverflow.com/questions/7360403/base-64-encode-and-decode-example-code