Base 64 encode and decode - Php
Base 64 encryption
Snippet Code
This snippet can be used to encode and decode a string in php.
<?php
function base64url_encode($plainText) {
$base64 = base64_encode($plainText);
$base64url = strtr($base64, ' /=', '-_,');
return $base64url;
}
function base64url_decode($plainText) {
$base64url = strtr($plainText, '-_,', ' /=');
$base64 = base64_decode($base64url);
return $base64;
}
echo base64url_encode("hiox")."
";
echo base64url_decode(base64url_encode("hiox"));
?>
Tags