Skip to content
forked from manu-kaushik/jwt

A simple library to sign and verify JWT.

License

Notifications You must be signed in to change notification settings

ruthv1k/jwt-php

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JWT PHP

Note : Uses HS256 algorithm only.

Usage

Requires a 256 bit secret key, needs to be generated manually.

$secret = 'R9YS96rZq0dD6m3NB72aeja6NqCph5y9';

Signing

$data = [
    'email' => 'johndoe@example.com',
    'password' => 'cDzHz0fI8z'
];

$token = JWT::sign($data, $secret);

Verifying

$token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6ImpvaG5kb2VAZXhhbXBsZS5jb20iLCJwYXNzd29yZCI6ImNEekh6MGZJOHoifQ.s_3pSzPZBK_xk9ESqSoNctRv-20VvF8CjkHNWxCO-eQ';

$result = JWT::verify($token, $secret);

verify method returns payload if token is valid, else returns 'Invalid Token'.

About

A simple library to sign and verify JWT.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%