PHPackages                             bllohar/php-jwt-class-with-rsa-support - 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. bllohar/php-jwt-class-with-rsa-support

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

bllohar/php-jwt-class-with-rsa-support
======================================

PHP Implementation of JSON Web token with RSA.

9964↓100%6PHP

Since Jul 16Pushed 10y ago1 watchersCompare

[ Source](https://github.com/bllohar/php-jwt-class-with-RSA-support)[ Packagist](https://packagist.org/packages/bllohar/php-jwt-class-with-rsa-support)[ RSS](/packages/bllohar-php-jwt-class-with-rsa-support/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

PHP JWT Tokens with RSA Support
===============================

[](#php-jwt-tokens-with-rsa-support)

PHP Implementation of JSON Web token with RSA.

I needed a JWT support for one client mobile application with RSA public/private keys.

I thought i should share with you all. Feel free to modify and use in your project.

Supported algos : RSA (Public Key/Private Key pair)

```
RS256 - RSA using SHA-256 hash algorithm
RS384 - RSA using SHA-384 hash algorithm
RS512 - RSA using SHA-512 hash algorithm

HMAC Algos :

HS256 - HMAC using SHA-256 hash algorithm (default)
HS384 - HMAC using SHA-384 hash algorithm
HS512 - HMAC using SHA-512 hash algorithm

```

How to use with RSA public/private key
======================================

[](#how-to-use-with-rsa-publicprivate-key)

With composer

```
composer require bllohar/php-jwt-class-with-rsa-support
```

Or

##### git clone

[](#git-clone-httpsgithubcomblloharphp-jwt-class-with-rsa-supportgit)

```
include 'php-jwt-class-with-RSA-support/src/JWToken.php';
```

```
$payload = array(
		'username' => 'bllohar',
		'userId'   => 1
);

//Please do not use key provided here in production they are just for demo.
$private_key = file_get_contents('keys/private_key.pem');
$public_key = file_get_contents('keys/public_key.pem');

// Generate token with Private key
$token = JWToken::encode($payload, $private_key,'RS256');

// Verifying the token
try{
	$data = JWToken::decode($token,$public_key,'RS256');

        var_dump($data);
}catch(Exception $e){
	echo $e->getMessage();
}
```

How to use with HMAC
====================

[](#how-to-use-with-hmac)

```
$payload = array(
		'username' => 'bllohar',
		'userId'   => 1
);

$secret = "^&562!2wzJGH!222"; // your secret key [should store in ENV variable]

// Generate token with secret
$token = JWToken::encode($payload, $secret,'HS512');

// Verifying the token
try{
	    $data = JWToken::decode($token,$secret,'HS512');
        var_dump($data);
}catch(Exception $e){
	echo $e->getMessage();
}
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/49430545b67ba99e289702a63151e5477dd8fcc6b1b8b311257da24b5d87880e?d=identicon)[bllohar](/maintainers/bllohar)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/bllohar-php-jwt-class-with-rsa-support/health.svg)

```
[![Health](https://phpackages.com/badges/bllohar-php-jwt-class-with-rsa-support/health.svg)](https://phpackages.com/packages/bllohar-php-jwt-class-with-rsa-support)
```

###  Alternatives

[namshi/jose

JSON Object Signing and Encryption library for PHP.

1.8k99.6M101](/packages/namshi-jose)[league/oauth1-client

OAuth 1.0 Client Library

99698.8M106](/packages/league-oauth1-client)[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[gesdinet/jwt-refresh-token-bundle

Implements a refresh token system over Json Web Tokens in Symfony

70516.4M35](/packages/gesdinet-jwt-refresh-token-bundle)[league/oauth2-google

Google OAuth 2.0 Client Provider for The PHP League OAuth2-Client

41721.2M118](/packages/league-oauth2-google)[illuminate/auth

The Illuminate Auth package.

9327.3M1.0k](/packages/illuminate-auth)

PHPackages © 2026

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