See the demo.
This script encodes to and decodes from base64. It allows you to specify a few parameters:
- The non-alphanumeric characters.
- The padding character, or lack thereof.
- 8-bit or 16-bit string input.
Your standard base64 uses
/ as the non-alphanumeric characters, and
= as the padding character. Now say you want base64url. No problem. Just use the following settings:
base64.settings.char62 = "-"; base64.settings.char63 = "_"; base64.settings.pad = null;
test.html contains a few tests.