Skip to content

nauxliu/jwt-simple

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jwt-simple

JWT(JSON Web Token) encode and decode module for PHP.

Install

$ composer require naux/jwt

Usage

$secret = 'xxx';

$jwt = new \Naux\JWT($secret); 
$payload = ['iss' => 1, 'exp' => 1450539234, 'foo' => 'bar'];

// encode
$token = $jwt->encode($payload);

// decode
$decoded = $jwt->decode($token);

var_dump($decoded);

Algorithms

By default the algorithm to encode is HS256.

The supported algorithms for encoding and decoding are ECDSA, ES256, ES384, ES512, HMAC, HS256, HS384, HS512, PublicKey, RS256, RS384, RS512, RSA.

// using HS512
$jwt = new JWT('secret', 'HS512');

About

JWT encode and decode module for PHP.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages