4 ms·
one of the main annoyances w/ base64 is when you want to it in the context of URLs https://en.wikipedia.org/wiki/Base64#URL_applications https://en.wikipedia.o
by tosh 6y ago
one of the main annoyances w/ base64 is when you want to it in the context of URLs
https://en.wikipedia.org/wiki/Base64#URL_applications https://en.wikipedia.org/wiki/Base64#URL_applications
> Using standard Base64 in URL requires encoding of '+', '/' and '=' characters into special percent-encoded hexadecimal sequences ('+' becomes '%2B', '/' becomes '%2F' and '=' becomes '%3D'), which makes the string unnecessarily longer.
- tracker1 6y agofor URIs, would use base64url. Replaces '+' with '-' and '/' with '_' while omitting the '=' padding.
- jillesvangurp 6y agoApache commons codec has a base 64 encoder that has a url friendly mode where it substitutes those characters. I've used that a few times to work around issues like this.
- brabel 6y agoURL-safe base64 is part of the spec: https://tools.ietf.org/html/rfc4648#section-5 https://tools.ietf.org/html/rfc4648#section-5 If you're using Java, it's right in the standard library: `Base64.getUrlEncoder().withoutPadding().encode(value)`