naux/jwt-simple

There is no license information available for the latest version (1.0.5) of this package.

1.0.5 2015-12-23 16:02 UTC

This package is auto-updated.

Last update: 2024-12-28 05:01:12 UTC


README

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');