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.
Replace all -
characters by +
and all _
characters by /
.
You now have Base64 with padding.
Base64 decoding should be available as a library for your favorite language...
Thanks, it looks like the repository was renamed. I copy the script here in case the repo disappears (could happen since Moodstocks has belonged to Google for years now...)