Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the smallest URL friendly encoding?

I am looking for a url encoding method that is most efficient in terms of space. Raw binary (base2) could be represented in base16 which is smaller and is url safe, but base64 is even more efficient. However, the usual base64 encoding isn't url safe....

So what is the smallest encoding method that is also safe for URLS?

like image 454
rook Avatar asked Oct 09 '22 03:10

rook


1 Answers

This is what the Base64 URL encoding variant is for.

It uses the same standard Base64 Alphabet except that + is changed to - and / is changed to _.

Most modern Base64 implementations will support this alternate encoding. If yours doesn't, it's usually just a matter of doing a search/replace on the Base64 input prior to decoding, or on the output prior to sending it to a browser.

like image 153
Flimzy Avatar answered Oct 10 '22 18:10

Flimzy