Created
July 10, 2014 23:05
-
-
Save muffycompo/a378dcfa73c3cf354eb8 to your computer and use it in GitHub Desktop.
PHP Helper functions for Safe Base64 URL encode
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($data) { | |
return rtrim(strtr(base64_encode($data), '+/', '-_'), '='); | |
} | |
function base64url_decode($data) { | |
return base64_decode(str_pad(strtr($data, '-_', '+/'), strlen($data) % 4, '=', STR_PAD_RIGHT)); | |
} | |
?> |
gnumoksha
commented
Oct 26, 2020
- Encode: https://github.com/firebase/php-jwt/blob/feb0e820b8436873675fd3aca04f3728eb2185cb/src/JWT.php#L350
- Decode: https://github.com/firebase/php-jwt/blob/feb0e820b8436873675fd3aca04f3728eb2185cb/src/JWT.php#L333
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment