Skip to content

Instantly share code, notes, and snippets.

@herdianf
Last active October 29, 2023 07:36
Show Gist options
  • Save herdianf/6ed2def10de57704997660f4641c2eda to your computer and use it in GitHub Desktop.
Save herdianf/6ed2def10de57704997660f4641c2eda to your computer and use it in GitHub Desktop.
BASE64 URL RFC4648
<?php
function base64url_encode($data) {
return $data ? rtrim(strtr(base64_encode($data), '+/', '-_'), '=') : '';
}
function base64url_decode($data) {
return $data ? base64_decode(strtr((string)$data, '-_', '+/'), TRUE) : '';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment