parent
53d97e35d2
commit
1fe7d2e5ff
@ -1,21 +0,0 @@ |
|||||||
<?php |
|
||||||
|
|
||||||
declare(strict_types=1); |
|
||||||
|
|
||||||
namespace tts; |
|
||||||
|
|
||||||
final class url_encode { |
|
||||||
|
|
||||||
/** |
|
||||||
* site http://php.net/manual/en/function.base64-encode.php |
|
||||||
*/ |
|
||||||
public static function base64url_encode(string $data): string { |
|
||||||
return rtrim(strtr(base64_encode($data), '+/', '-_'), '='); |
|
||||||
} |
|
||||||
|
|
||||||
public static function base64url_decode(string $data): string { |
|
||||||
//return base64_decode(str_pad(strtr($data, '-_', '+/'), strlen($data) % 4, '=', STR_PAD_RIGHT)); |
|
||||||
return base64_decode( strtr( $data, '-_', '+/') . str_repeat('=', 3 - ( 3 + strlen( $data )) % 4 )); |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
Loading…
Reference in new issue