Code: Select all
base64_encode ('451');
Decoding
Code: Select all
echo base64_decode('NDUx');
In .Net, this type of encoding is available at Viewstate
The problem here is, when Encoding a text into bas64, the '=' char is added and php scritpt is confused.
To avoid this, the following method can be used.
Code: Select all
function base64_url_encode($input)
{
return strtr(base64_encode($input), '+/=', '-_,');
}
function base64_url_decode($input)
{
return base64_decode(strtr($input, '-_,', '+/='));
}