Skip to content

Instantly share code, notes, and snippets.

@nirendra
Created November 27, 2013 23:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save nirendra/7685072 to your computer and use it in GitHub Desktop.
Save nirendra/7685072 to your computer and use it in GitHub Desktop.
Base64 Encode and Decode String in 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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment