3 ms·
Why would you consider Z85 to be a better choice? When you take URI encoding into account, Base64 is both simpler (no need for %-encoding)[0] and more space eff
by BrandonM 12y ago
Why would you consider Z85 to be a better choice? When you take URI encoding into account, Base64 is both simpler (no need for %-encoding)[0] and more space efficient (1.75 URI characters per byte for Z85, and 1.33 for Base64)[1]. The very first line on jwt.io says, JSON Web Token (JWT) is a compact URL-safe means of...; being URI-safe appears to be an explicit design decision.
[0] All but six of Z85's special characters get encoded by Javascript's encodeURIComponent:
: + = ^ / ? & < > [ ] { } @ % $ #
[1] URI-safe versions of Base64 (as used by JWT) use 4 characters for every 3 bytes. Z85 uses 5 characters for every four bytes, but 17 of those 85 characters require three URI characters to represent, meaning that a Z85-encoded byte requires 1.75 URI characters per byte on average:
(68 * 1 + 17 * 3) / 85 = 1.4 uri_chars/char
1.4 * 5 / 4 = 1.75 uri_chars/byte
- haakon 12y agoThanks, that's a nicely explained correction.