diff options
author | VirtualTam <virtualtam@flibidi.net> | 2018-12-03 00:16:10 +0100 |
---|---|---|
committer | VirtualTam <virtualtam@flibidi.net> | 2019-01-12 22:47:48 +0100 |
commit | 00af48d9d20af1ce51c8ad42fe354fafc9ceb8a3 (patch) | |
tree | d25bd47e03f7016af5fc8d2ea982b982fed9f54a /application/Base64Url.php | |
parent | dfc650aa239d3a2c028d0ba13132ce75b4f4c0b4 (diff) | |
download | Shaarli-00af48d9d20af1ce51c8ad42fe354fafc9ceb8a3.tar.gz Shaarli-00af48d9d20af1ce51c8ad42fe354fafc9ceb8a3.tar.zst Shaarli-00af48d9d20af1ce51c8ad42fe354fafc9ceb8a3.zip |
namespacing: \Shaarli\Http\Base64Url
Signed-off-by: VirtualTam <virtualtam@flibidi.net>
Diffstat (limited to 'application/Base64Url.php')
-rw-r--r-- | application/Base64Url.php | 35 |
1 files changed, 0 insertions, 35 deletions
diff --git a/application/Base64Url.php b/application/Base64Url.php deleted file mode 100644 index 54d0fcd5..00000000 --- a/application/Base64Url.php +++ /dev/null | |||
@@ -1,35 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Shaarli; | ||
4 | |||
5 | /** | ||
6 | * URL-safe Base64 operations | ||
7 | * | ||
8 | * @see https://en.wikipedia.org/wiki/Base64#URL_applications | ||
9 | */ | ||
10 | class Base64Url | ||
11 | { | ||
12 | /** | ||
13 | * Base64Url-encodes data | ||
14 | * | ||
15 | * @param string $data Data to encode | ||
16 | * | ||
17 | * @return string Base64Url-encoded data | ||
18 | */ | ||
19 | public static function encode($data) | ||
20 | { | ||
21 | return rtrim(strtr(base64_encode($data), '+/', '-_'), '='); | ||
22 | } | ||
23 | |||
24 | /** | ||
25 | * Decodes Base64Url-encoded data | ||
26 | * | ||
27 | * @param string $data Data to decode | ||
28 | * | ||
29 | * @return string Decoded data | ||
30 | */ | ||
31 | public static function decode($data) | ||
32 | { | ||
33 | return base64_decode(str_pad(strtr($data, '-_', '+/'), strlen($data) % 4, '=', STR_PAD_RIGHT)); | ||
34 | } | ||
35 | } | ||