PHPackages                             shota/jwt-covertor - 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. shota/jwt-covertor

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

shota/jwt-covertor
==================

A simple jwt convertor

v1.0.0(4y ago)01MITPHPPHP &gt;=7.2.0|^8.0

Since Aug 9Pushed 4y ago1 watchersCompare

[ Source](https://github.com/YaoMiss/jwt-convertor-php)[ Packagist](https://packagist.org/packages/shota/jwt-covertor)[ Docs](https://github.com/YaoMiss/jwt-convertor-php)[ RSS](/packages/shota-jwt-covertor/feed)WikiDiscussions main Synced today

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

PHP JWT Convertor
=================

[](#php-jwt-convertor)

Dependence
----------

[](#dependence)

- PHP version : `>=7.2.0|^8.0`
- php-ext : `openssl` 、`mbstring` 、`sodium`

Algorithm
---------

[](#algorithm)

AlgoIncluingSupportCommentHMAC with SHA-2HS256 HS384 HS512YesEC DSA signature with SHA-2ES256 ES384 ES512YesShort SlowRSA signature with PKCS #1 and SHA-2RS256 RS384 RS512YesLong FastRSA PSS signature with SHA-2PS256 PS384 PS512NoEdwards-curve DSA signature with SHA-2EdDSAYesInstallation
------------

[](#installation)

```
composer require shota/jwt-covertor
```

Generate Key
------------

[](#generate-key)

RSA (RSA signature with PKCS #1 and SHA-2)
------------------------------------------

[](#rsa-rsa-signature-with-pkcs-1-and-sha-2)

> Advance : Key long but fast

```
# generate the private key
bash > openssl
> genrsa -out rsa_private_key.pem 2048

# generate the public key
bash > openssl
> rsa -in rsa_private_key.pem -pubout -out rsa_public_key.pem
```

ECS (EC DSA signature with SHA-2)
---------------------------------

[](#ecs-ec-dsa-signature-with-sha-2)

> Advance : Key short but slow

```
# generate the private key
bash > openssl ecparam -name secp256k1 -genkey -out privateKey.pem

# generate the public key
bash > openssl ec -in privateKey.pem -pubout -out publicKey.pem
```

EdDSA (Edwards-curve DSA signature with SHA-2)
----------------------------------------------

[](#eddsa-edwards-curve-dsa-signature-with-sha-2)

```
// $sign_seed = random_bytes(SODIUM_CRYPTO_SIGN_SEEDBYTES);
// $sign_pair = sodium_crypto_sign_seed_keypair($sign_seed);

$sign_pair = sodium_crypto_sign_keypair();
$sign_secret = sodium_crypto_sign_secretkey($sign_pair);
$sign_public = sodium_crypto_sign_publickey($sign_pair);

$message = 'Hello';

$signature = sodium_crypto_sign_detached($message, $sign_secret);
$message_valid = sodium_crypto_sign_verify_detached($signature, $message, $sign_public);
```

Usage
-----

[](#usage)

### Example With HMAC

[](#example-with-hmac)

```
use Shota\JWT\JWT;

$key = 'encode-key';
$payload = [
        "iss" => "John Doe",
        "exp" => time() + 100000,
        "sub" => "unit-test-01",
        "aud" => "all",
        "nbf" => time(),
        "iat" => time(),
        "jti" => time(),

        "name" => "John Doe",
        "admin" => true,
];
$jwtStr = JWT::encode($this->payload, $key, 'HS512');
echo sprintf('jwt : %s \n',jwtStr);

$decodePayload = JWT::decode($jwtStr,$key)
print_r($decodePayload);
```

### Example With EC DSA Signature

[](#example-with-ec-dsa-signature)

```
use Shota\JWT\JWT;

$privateKey = file_get_contents(__DIR__ . '/cert/ecs-private-key.pem');
$publicKey =  file_get_contents(__DIR__ . '/cert/ecs-public-key.pem');

$payload = [
    "iss" => "John Doe",
    "exp" => time() + 100000,
    "sub" => "unit-test-01",
    "aud" => "all",
    "nbf" => time(),
    "iat" => time(),
    "jti" => time(),

    "name" => "John Doe",
    "admin" => true,
];
$jwtStr = JWT::encode($this->payload, $privateKey, 'HS512');
echo sprintf('jwt : %s \n',jwtStr);

$decodePayload = JWT::decode($jwtStr,$publicKey)
print_r($decodePayload);
```

### Example With RSA Signature

[](#example-with-rsa-signature)

```
use Shota\JWT\JWT;

$privateKey = file_get_contents(__DIR__ . '/cert/rsa-private-key.pem');
$publicKey = file_get_contents(__DIR__ . "/cert/rsa-public-key.pem");

$payload = [
    "iss" => "John Doe",
    "exp" => time() + 100000,
    "sub" => "unit-test-01",
    "aud" => "all",
    "nbf" => time(),
    "iat" => time(),
    "jti" => time(),

    "name" => "John Doe",
    "admin" => true,
];

$jwtStr = JWT::encode($this->payload, $privateKey, 'HS512');
echo sprintf('jwt : %s \n',jwtStr);

$decodePayload = JWT::decode($jwtStr,$publicKey)
print_r($decodePayload);
```

### Example With EdDSA

[](#example-with-eddsa)

```
use Shota\JWT\JWT;

$payload = [
    "iss" => "John Doe",
    "exp" => time() + 100000,
    "sub" => "unit-test-01",
    "aud" => "all",
    "nbf" => time(),
    "iat" => time(),
    "jti" => time(),

    "name" => "John Doe",
    "admin" => true,
];

$signPair = sodium_crypto_sign_keypair();
$secret = sodium_crypto_sign_secretkey($signPair);
$publicKey = sodium_crypto_sign_publickey($signPair);

$jwtStr = JWT::encode($payload, $secret, 'EdDSA');
echo sprintf('jwt : %s \n',jwtStr);

$decodePayload = JWT::decode(jwtStr, publicKey);
print_r($decodePayload);
```

Tests
-----

[](#tests)

```
bash > composer require --dev phpunit/phpunit
bash > vendor/bin/phpunit  --configuration phpunit.xml.dist

```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity1

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

1734d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/20b5b5de1ffd7cdc1108882410d21b4a162f24e39d044450cc9a48cabae29b29?d=identicon)[Packie](/maintainers/Packie)

---

Top Contributors

[![biyongyao](https://avatars.githubusercontent.com/u/30311203?v=4)](https://github.com/biyongyao "biyongyao (4 commits)")

---

Tags

phpjwt

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/shota-jwt-covertor/health.svg)

```
[![Health](https://phpackages.com/badges/shota-jwt-covertor/health.svg)](https://phpackages.com/packages/shota-jwt-covertor)
```

###  Alternatives

[griffinledingham/php-apple-signin

A simple library to decode and parse Apple Sign In client tokens.

2011.9M1](/packages/griffinledingham-php-apple-signin)[hyperf-ext/jwt

The Hyperf JWT package.

53134.9k2](/packages/hyperf-ext-jwt)[maicol07/flarum-ext-sso

SSO for Flarum

468.3k](/packages/maicol07-flarum-ext-sso)

PHPackages © 2026

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