Simple php function to encode and decode a string in php. This function uses simple base64_encode to encode the string.
function base64url_encode($mytext) {
$base64 = base64_encode($mytext);
$base64url = strtr($base64, '+/=', '-_,');
return $base64url;
}
function base64url_decode($mytext) {
$base64url = strtr($mytext, '-_,', '+/=');
$base64 = base64_decode($base64url);
return $base64;
}
function base64url_encode($mytext) {
$base64 = base64_encode($mytext);
$base64url = strtr($base64, '+/=', '-_,');
return $base64url;
}
function base64url_decode($mytext) {
$base64url = strtr($mytext, '-_,', '+/=');
$base64 = base64_decode($base64url);
return $base64;
}
No comments:
Post a Comment