| 123456789101112131415161718192021222324252627 |
- <?php
- declare(strict_types=1);
- /**
- * This file is part of qbhy/simple-jwt.
- *
- * @link https://github.com/qbhy/simple-jwt
- * @document https://github.com/qbhy/simple-jwt/blob/master/README.md
- * @contact qbhy0715@qq.com
- * @license https://github.com/qbhy/simple-jwt/blob/master/LICENSE
- */
- namespace Qbhy\SimpleJwt\Encoders;
- use Qbhy\SimpleJwt\Interfaces\Encoder;
- class Base64UrlSafeEncoder implements Encoder
- {
- public function encode(string $string): string
- {
- return rtrim(strtr(base64_encode($string), '+/', '-_'), '=');
- }
- public function decode(string $string): string
- {
- return base64_decode(strtr($string, '-_', '+/'));
- }
- }
|