Skip to content

Instantly share code, notes, and snippets.

@LianSheng197
Forked from nathggns/base64url.php
Created December 27, 2021 10:21
Show Gist options
  • Save LianSheng197/c9d714aea6d56aba8c9ad601908139d5 to your computer and use it in GitHub Desktop.
Save LianSheng197/c9d714aea6d56aba8c9ad601908139d5 to your computer and use it in GitHub Desktop.
base64url functionality for php
<?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));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment