Skip to content

Instantly share code, notes, and snippets.

@telamon
Created December 29, 2023 17:15
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 telamon/d6cffb14f60e3ef0899861acfb14110a to your computer and use it in GitHub Desktop.
Save telamon/d6cffb14f60e3ef0899861acfb14110a to your computer and use it in GitHub Desktop.

For a custom encoding using URL fragment-safe characters, you can go beyond Base64.
Considering alphanumeric characters (A-Z, a-z, 0-9), which give you 62 characters,
and adding safe special characters like:

-_.~!$&'()*+,;=:@?/#[]

(which are 22 in total), you can potentially reach a base count of around 84 (62 + 22).

This would be a custom base-84 encoding, utilizing these URL-safe characters to maximize space efficiency.

Encoding Bits per Character
Base16 (Hex) 4
Base64 URL-safe 6
Base84 6.39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment