Skip to content

Instantly share code, notes, and snippets.

@gr8pathik
Created December 3, 2013 07:27
Show Gist options
  • Save gr8pathik/7765304 to your computer and use it in GitHub Desktop.
Save gr8pathik/7765304 to your computer and use it in GitHub Desktop.
Base64 Encode and Decode 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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment