Skip to content

Instantly share code, notes, and snippets.

@hthuong09
Forked from catwell/b64url-np.md
Created November 14, 2019 17:58
Show Gist options
  • Save hthuong09/9c9842628fd5afec6921eadd3cf66792 to your computer and use it in GitHub Desktop.
Save hthuong09/9c9842628fd5afec6921eadd3cf66792 to your computer and use it in GitHub Desktop.
Decoding Base64-URL without padding

Decoding Base64-URL without padding

1) Add padding

Divide the length of the input string by 4, take the remainder. If it is 2, add two = characters at the end. If it is 3, add one = character at the end.

You now have Base64-URL with padding.

2) Translate to Base64

Replace all - characters by + and all _ characters by /.

You now have Base64 with padding.

3) Decode Base64

Base64 decoding should be available as a library for your favorite language...

Examples

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