Skip to content

Instantly share code, notes, and snippets.

@aegis123
Created July 17, 2013 14:20
Show Gist options
  • Save aegis123/6020974 to your computer and use it in GitHub Desktop.
Save aegis123/6020974 to your computer and use it in GitHub Desktop.
encode a string with Base64 url safe and no padding
byte[] digist;
Base64.encodeToString(digest, Base64.URL_SAFE | Base64.NO_PADDING);
@JoshMcCullough
Copy link

For Java8+ ...

Base64.getUrlEncoder().encode(digest);

... and ...

Base64.getUrlDecoder().decode(digest);

@adrian-hoehn
Copy link

new String(Base64.getUrlEncoder().encode(digest)).split("=")[0] //remove padding

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment