Download the PHP package iachilles/pjwt without Composer
On this page you can find all versions of the php package iachilles/pjwt. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download iachilles/pjwt
More information about iachilles/pjwt
Files in iachilles/pjwt
Package pjwt
Short Description PHP implementation of JSON Web Token (JWT). It provides a simple way to create, sign and verify JWT.
License AGPL License 3.0
Homepage https://github.com/iAchilles/pjwt
Informations about the package pjwt
pJWT
PHP implementation of JSON Web Token (JWT). It provides a simple way to create, sign and verify JWT.
The following features are supported:
- Built-in validation for the JWT claims (iat, nbf, exp, jti).
-
Symmetric and asymmetric algorithms for protecting integrity:
Symmetric Asymmetric HS256 RS256 HS384 RS384 HS512 RS512
Requirements
PHP 5.4.0 or above.
Installation
Use composer to install pJWT:
Code examples
-
Creating JWT
-
by using symmetric algorithm HS256:
- by using asymmetric algorithm RS256:
If the private key is encrypted with a password, you can use the following format:
- with protection from replay attacks. In order to protect from replay attacks, you can set 'jti' claim to TRUE during creation JWT.
-
-
Decoding and verifying JWT
Verifying signature
If the signature is valid, you have to validate the JWT claims.
To validate "jti" value you need to create two anonymous functions, and pass them as arguments to the verify method.