PHP Classes

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

Recommend this page to a friend!
  Info   View files Documentation   View files View files (5)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog (1)    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 234 This week: 1All time: 8,099 This week: 560Up
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: 29051 in Congo Congo
Week rank: 106 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  
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  /  src  
File Role Description
  Plain text file JWT.php Class Class source

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

 Version Control Unique User Downloads Download Rankings  
 100%
Total:234
This week:1
All time:8,099
This week:560Up
User Comments (1)
That's a very great class ;-)
1 year ago (José Filipe Lopes Santos)
80%StarStarStarStarStar