2017 © Pedro PelĂĄez
 

library jwt

PHP Implementation of JSON Web token with RSA

image

xaamin/jwt

PHP Implementation of JSON Web token with RSA

  • Tuesday, September 12, 2017
  • by xaamin
  • Repository
  • 1 Watchers
  • 1 Stars
  • 55 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 3 Versions
  • 10 % Grown

The README.md

PHP JWT Tokens with RSA Support

PHP Implementation of JSON Web token with RSA., (*1)

Supported algorithms:

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 algorithms : 

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

Install

With composer, (*2)

composer require xaamin/jwt
````

# How to use with RSA public/private key

Set configuration in **src/Config/config.php**. Don't use key provided here in production.

'algorithm' => 'RS512',

// ... Other stuff here

'keys' => [
    'public' => '../keys/public_key.pem',
    'private' => '../keys/private_key.pem',

    'passphrase' => null,
],


```php $payload = [ 'sub' => 1, 'username' => 'xaamin' ]; // Generate token $token = Xaamin\JWT\Facade\Native\JWT::encode($payload); // Verify the token try{ $token = Xaamin\JWT\Facade\Native\JWT::decode($token->get()); var_dump($token); } catch (Exception $e) { echo $e->getMessage(); }

How to use with HMAC

Set configuration in src/Config/config.php, (*3)

    'algorithm' => 'HS512',

    'secret' => 'some-random-string'
    $payload = [
            'sub'   => 1,
            'username' => 'xaamin'
        ];

    // Generate token
    $token = Xaamin\JWT\Facade\Native\JWT::encode($payload);

    // Verify the token
    try{
        $token = Xaamin\JWT\Facade\Native\JWT::decode($token->get());

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

The Versions

12/09 2017

dev-master

9999999-dev

PHP Implementation of JSON Web token with RSA

  Sources   Download

MIT

The Requires

  • php >=5.4

 

jwt token laravel jwt

12/09 2017

v1.0.10

1.0.10.0

PHP Implementation of JSON Web token with RSA

  Sources   Download

MIT

The Requires

  • php >=5.4

 

jwt token laravel jwt

13/09 2016

v1.0.1

1.0.1.0

PHP Implementation of JSON Web token with RSA

  Sources   Download

MIT

The Requires

  • php >=5.4

 

jwt token laravel jwt