Using base64 to encode your data

Recently, I have got a project that requires a Web Service to transport data back and forth between an Android application and Linux server.  As you know, Android also supports JSON to transfer data and communicate with a web service that way. So, we decided to use base64 as a middle man to save and retrieve data. The design point is that a user can upload data and pictures from an Android to the database in cloud. Then later on, data can be retrieved using a web-based application.

This base64 encoding is designed to make binary data survive transport through transport layers that are not 8-bit clean, such as mail bodies. Base64-encoded data takes about 33% more space than the original data. There’s a give and take for using base64 here. The pros is base64 string is pretty small and it protects your data if there’s special characters exist. The cons is that during the retrieving data, if 1 character missing in the base64 encoded string, you can’t read the entire data set.

How to encode your data:
string base64_encode ( string $your_data )
$your_data variable can be mixed data including arrays, text, string, numeric,...
The encoded string can be as simple as this
VGhpcyBpcyBhbiBlbmNvZGVkIHN0cmluZw==

How to retrieve your data from a base64 encoded string:
string base64_decode ( string $your_encoded_data [, bool $strict = false ] )
$strick returns FALSE if input contains character from outside the base64 alphabet.