Tuesday, October 1, 2013

[PHP] - Encode / Decode paramater on the URL using base64


function my_base64_encode($input) {
	return strtr(base64_encode($input), 'AEIOUj', '+-_,');
}
 
function my_base64_decode($input){
	return base64_decode(strtr($input, '+-_,', 'AEIOUj'));
}

$texttoencode = 'RAIHAN';

$b = my_base64_encode($texttoencode);
// the value of $b now is UkFJS-F,

$c = my_base64_decode($b);
// the value of $c is RAIHAN


No comments:

Post a Comment