Skip to content

Instantly share code, notes, and snippets.

@luctrudeau
Last active August 29, 2015 14:23
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 luctrudeau/dd20e7b35efe60efa608 to your computer and use it in GitHub Desktop.
Save luctrudeau/dd20e7b35efe60efa608 to your computer and use it in GitHub Desktop.
Android Base64 Example
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");
@luctrudeau
Copy link
Author

@luctrudeau
Copy link
Author

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