PHPackages                             hailong/jose - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. hailong/jose

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

hailong/jose
============

JWT, JWS and JWE implementation in PHP

3.0.2(3y ago)315.1k↓37%3[1 PRs](https://github.com/Hailong/jose-php/pulls)MITPHPPHP &gt;=5.6

Since Apr 25Pushed 2y agoCompare

[ Source](https://github.com/Hailong/jose-php)[ Packagist](https://packagist.org/packages/hailong/jose)[ Docs](https://github.com/hailong/jose)[ RSS](/packages/hailong-jose/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (17)Used By (0)

JOSE
====

[](#jose)

PHP JOSE (Javascript Object Signing and Encryption) Implementation

[![PHP Composer](https://github.com/Hailong/jose-php/actions/workflows/php.yml/badge.svg?branch=master)](https://github.com/Hailong/jose-php/actions/workflows/php.yml)

Requirements
------------

[](#requirements)

phpseclib is required.

Example
-------

[](#example)

### JWT

[](#jwt)

#### Encoding

[](#encoding)

```
$jwt = new JOSE_JWT(array(
    'foo' => 'bar'
));
$jwt->toString();
```

#### Decoding

[](#decoding)

```
$jwt_string = 'eyJ...';
$jwt = JOSE_JWT::decode($jwt_string);
```

### JWS

[](#jws)

#### Signing

[](#signing)

```
$private_key = "-----BEGIN RSA PRIVATE KEY-----\n....";
$jwt = new JOSE_JWT(array(
    'foo' => 'bar'
));
$jws = $jwt->sign($private_key, 'RS256');
```

NOTE: `$private_key` can be `phpseclib\Crypt\RSA` instance.

#### Verification

[](#verification)

```
$public_key = "-----BEGIN RSA PUBLIC KEY-----\n....";
$jwt_string = 'eyJ...';
$jws = JOSE_JWT::decode($jwt_string);
$jws->verify($public_key, 'RS256');
```

NOTE: `$public_key` can be `JOSE_JWK` or `phpseclib\Crypt\RSA` instance.

### JWE

[](#jwe)

#### Encryption

[](#encryption)

```
$jwe = new JOSE_JWE($plain_text);
$jwe->encrypt(file_get_contents('/path/to/public_key.pem'));
$jwe->toString();
```

#### Decryption

[](#decryption)

```
$jwt_string = 'eyJ...';
$jwe = JOSE_JWT::decode($jwt_string);
$jwe->decrypt($private_key);
```

### JWK

[](#jwk)

#### Encode

[](#encode)

##### RSA Public Key

[](#rsa-public-key)

```
$public_key = new phpseclib\Crypt\RSA();
$public_key->loadKey('-----BEGIN RSA PUBLIC KEY-----\n...');
JOSE_JWK::encode($public_key); # => JOSE_JWK instance
```

##### RSA Private Key

[](#rsa-private-key)

```
$private_key = new phpseclib\Crypt\RSA();
$private_key->setPassword($pass_phrase); # skip if not encrypted
$private_key->loadKey('-----BEGIN RSA PRIVATE KEY-----\n...');
JOSE_JWK::encode($private_key); # => JOSE_JWK instance
```

#### Decode

[](#decode)

##### RSA Public Key

[](#rsa-public-key-1)

```
# public key
$components = array(
    'kty' => 'RSA',
    'e' => 'AQAB',
    'n' => 'x9vNhcvSrxjsegZAAo4OEuo...'
);
JOSE_JWK::decode($components); # => phpseclib\Crypt\RSA instance
```

##### RSA Private Key

[](#rsa-private-key-1)

Not supported.

Run Test
--------

[](#run-test)

```
git clone git://github.com/nov/jose-php.git
cd jose
php composer.phar install --dev
./vendor/bin/phpunit -c test/phpunit.xml --tap
```

Copyright
---------

[](#copyright)

Copyright © 2013 Nov Matake &amp; GREE Inc. See LICENSE for details.

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity30

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 60.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~222 days

Recently: every ~525 days

Total

16

Last Release

1432d ago

Major Versions

0.1.5 → 1.0.02014-10-03

1.0.1 → 2.0.02015-08-10

2.2.1 → 3.0.02022-06-17

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/354776?v=4)[hailong](/maintainers/hailong)[@Hailong](https://github.com/Hailong)

---

Top Contributors

[![nov](https://avatars.githubusercontent.com/u/27299?v=4)](https://github.com/nov "nov (42 commits)")[![Hailong](https://avatars.githubusercontent.com/u/354776?v=4)](https://github.com/Hailong "Hailong (10 commits)")[![peter-svintsitskyi](https://avatars.githubusercontent.com/u/1718328?v=4)](https://github.com/peter-svintsitskyi "peter-svintsitskyi (8 commits)")[![vincib](https://avatars.githubusercontent.com/u/358692?v=4)](https://github.com/vincib "vincib (5 commits)")[![sasezaki](https://avatars.githubusercontent.com/u/42755?v=4)](https://github.com/sasezaki "sasezaki (3 commits)")[![ledmonster](https://avatars.githubusercontent.com/u/975452?v=4)](https://github.com/ledmonster "ledmonster (1 commits)")

---

Tags

jwtJWSJWEJOSEJSON Web TokenJSON Web SignatureOpenID ConnectJSON Web EncryptionID Token

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/hailong-jose/health.svg)

```
[![Health](https://phpackages.com/badges/hailong-jose/health.svg)](https://phpackages.com/packages/hailong-jose)
```

###  Alternatives

[namshi/jose

JSON Object Signing and Encryption library for PHP.

1.8k99.6M101](/packages/namshi-jose)[sop/jwx

A PHP library for JSON web tokens (JWT) with signature (JWS) and encryption (JWE) support.

26257.5k1](/packages/sop-jwx)[web-token/jwt-framework

JSON Object Signing and Encryption library for PHP and Symfony Bundle.

94818.9M77](/packages/web-token-jwt-framework)[web-token/jwt-library

JWT library

2011.2M83](/packages/web-token-jwt-library)[web-token/jwt-bundle

JWT Bundle of the JWT Framework.

132.5M7](/packages/web-token-jwt-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
