derrickleemy / jwe-decoder
An simple JSON Web Token library for PHP.
v1.0.0
2020-03-19 15:42 UTC
Requires
- php: >=5.4.0
- ext-hash: *
- ext-openssl: *
Requires (Dev)
- ext-bz2: *
- ext-phar: *
- phing/phing: 2.*
- phpunit/phpunit: 4.*
- symfony/console: 2.7.*
This package is auto-updated.
Last update: 2025-02-20 02:53:14 UTC
README
JWEDecoder is a lightweight encrypted JWT decoder library written in PHP. It was originally written by Kevin Mo (all credits goes to him), and dialed down for a very specific use case for internal use.
Features
- JSON web encryption RFC7516
- Supported Algorithms
- RSAES with OAEP (RSA-OAEP-256)
Requirements
- PHP 5.4.0 or later
hash
extensionopenssl
extension
Installation
You can install via Composer.
composer require derrickleemy/jwe-decoder
{ "require": { "derrickleemy/jwe-decoder": "1.0.*" } }
Usage
Private Key
Private key is required to decode the JWE token. You can add your key by doing the following:
$key = file_get_contents('private.pem');
Decrypting a JWE
To decrypt a JWE, use the decrypt function:
try { $jwt = \JWEDecoder\JWE::decrypt('abc.def.ghi.klm.nop', $key); } catch (\JWEDecoder\InvalidTokenException $e) { dd($e->getMessage()); } print $jwt->getHeader('alg'); print $jwt->getPlaintext(); print $jwt->getRtHash(); print $jwt->getNonce(); print $jwt->getAmr(); print $jwt->getIat(); print $jwt->getIss(); print $jwt->getSub(); print $jwt->getAtHash(); print $jwt->getExp(); print $jwt->getAud();
Authors
Credits
- derrickleemy derrickleemy/jwe-decoder
- kevinmo kelvinmo/simplejwt