PHP Classes

PHP JWT Decode and Generate: Generate JWT tokens and decode token values

Recommend this page to a friend!
  Info   Documentation   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 241 All time: 8,028 This week: 64Up
Version License PHP version Categories
web_token 1.0.0The PHP License5PHP 5, Cryptography
Description 

Author

This class can generate JWT tokens and decode token values.

It can take an array of parameters and can generate a token string according to the JSON Web Token specification.

The class can also take a JWT token string and decode it to extract the original token parameter values into an array.

Innovation Award
PHP Programming Innovation award nominee
June 2022
Number 8
JSON Web Token (JWT) is a standard for encoding and transmitting security-sensitive information using JSON format to encode objects as strings.

This class provides a simple means to encode and decode data using the JWT standard.

Developers can use this class with other components that implement more complex protocols and security measures, like OAuth.

Manuel Lemos
Picture of Boss Ibrahim Mussa
  Performance   Level  
Name: Boss Ibrahim Mussa <contact>
Classes: 13 packages by
Country: Congo Congo
Age: ???
All time rank: 28891 in Congo Congo
Week rank: 132 Up1 in Congo Congo Equal
Innovation award
Innovation award
Nominee: 5x

Documentation

web_token

simple module to help generate a simple token using php

INTEGRATION

create a new instance of the class JWT, that will help you generate a new token, or validate an existing token.

    $data=[
        "data"=>"hello Github",
        "expired"=>300
    ];
    $tken= new JWT;
    $_token=$tken->generate($data)
    echo $_token;

the class Token has 2 Method: * generate: use this method to generate a new token key. it take 2 params. - the first parameter is an array of information according to the data to be encoded. it has 2 key : 1: data: where you can store all your information you want to be enconded; 2: expired:(iptional) how long your token will be used; the value in second, and it optional, by default the token propose 3600 second.

- the second parameter (optional) is cypherkye to encode your data, by default the token generate a cypherkey for the token key.

* decode use this method to valid your token, and restore the encoded the data, and it take 2 parameters.

- the first parameter is your token string generated with is devide in 3 parts: the encryption_iv,the encoded_data,the cypherkye.

    $tken = new JWT();
    $token = "4edc3e02a3ccf20c213131efa271b79b.vJjR1CIHHdfiCj4Tt+weTtnAZ7PVQw7e1eeQtdT3/qWY43pZH91r9mO92UhXrJB2NGoSv10j.c2f8ab9f30e19e14d47a6491ca77fe36";

    $dec = $tken->decode($token);
    var_dump($dec);

- the second parameter (optional) is cypherkye to encode your data, by default the token generate a cypherkey for the token key.


  Files folder image Files (5)  
File Role Description
Files folder imagesrc (1 file)
Files folder imagetest (1 file)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file index.php Aux. Auxiliary script
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files (5)  /  src  
File Role Description
  Plain text file JWT.php Class Class source

  Files folder image Files (5)  /  test  
File Role Description
  Accessible without login Plain text file index.php Example Example script

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:241
This week:0
All time:8,028
This week:64Up
User Comments (1)
That's a very great class ;-)
2 years ago (José Filipe Lopes Santos)
80%StarStarStarStarStar