nauxliu / jwt-simple

JWT encode and decode module for PHP.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

License:MIT License


Languages

Language:PHP 100.0%