Created
February 2, 2014 11:24
-
-
Save bladeofsteel/8766906 to your computer and use it in GitHub Desktop.
Encode and Decode a String using Base64 scheme
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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