Even though Base64 encoding is not an encryption, sometimes it can be useful to pass data or parameters in a single string.

Base64 is very useful for that, it is possible to encode a lot of types of data and it’s native to most programming languages, even PHP.

One thing to note when passing Bas64 in the URL is that Base64 generates characters with are not suitable to transfer as data (they are part of the URL structure): “+”,”=”,”/”. So before we can send them in the URL, we need to replace them with URL-safe characters, this can be done with the built-in functions urlencode() and urldecode(). For that, I wrote two basic functions, one for encoding Base64 data for sending as a parameter with the URL, and the second one for decoding a parameter received with the URL.

Base64 Encode for URL:

Base64 Decode for URL:


Leave a comment