]>
git.immae.eu Git - github/shaarli/Shaarli.git/blob - application/Base64Url.php
7 * URL-safe Base64 operations
9 * @see https://en.wikipedia.org/wiki/Base64#URL_applications
14 * Base64Url-encodes data
16 * @param string $data Data to encode
18 * @return string Base64Url-encoded data
20 public static function encode($data) {
21 return rtrim(strtr(base64_encode($data), '+/', '-_'), '=');
25 * Decodes Base64Url-encoded data
27 * @param string $data Data to decode
29 * @return string Decoded data
31 public static function decode($data) {
32 return base64_decode(str_pad(strtr($data, '-_', '+/'), strlen($data) %
4, '=', STR_PAD_RIGHT
));