dev-master
9999999-devA simple JSON Web Token Library.
Apache-2.0
The Development Requires
by Gyanendro Khomdram
v0.0.1
0.0.1.0A simple JSON Web Token Library.
Apache-2.0
The Development Requires
by Gyanendro Khomdram
A simple JSON Web Token Library.
$ composer require archphp/jwt
<?php require_once '{path/to/vendor}/autoload.php'; use Arch\JWT\JWT; use Arch\JWT\Token\Header; use Arch\JWT\Token\Payload; use Arch\JWT\Token\Algorithm\HS256; use Arch\JWT\Token\Claim\Subject; $alg = new HS256('secret'); $typ = 'JWT'; $header = new Header($alg, $typ); $payload = new Payload([ Subject::$name => 'arch', 'custom_claim' => 'custom_value' ]); /** * @see \Arch\JWT\Token\Claim for all available claims */ $jwt = new JWT($header, $payload); // This will print out the encrypted JWT. echo $jwt->getJWT();
<?php use Arch\JWT\JWT; use Arch\JWT\Exception\InvalidJWTException; use Arch\JWT\Exception\VerifierException; $t = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJBcmNoIn0.kq-ax6J9QPjDcT9Gx4ZPwP-L-FBY_rnEE5i_2ec2X7o'; // The secret key used in encrypting the JWT. $secret = 'Arch01'; // JWT::decode will throw an Exception if the JWT is invalid or claims are not verified. try { $jwt = JWT::decode($t, $secret); } catch(InvalidJWTException|VerifierException $e) { echo $e->getMessage(); }
A simple JSON Web Token Library.
Apache-2.0
A simple JSON Web Token Library.
Apache-2.0