This is an example of how to decode PWT generated tokens and encode tokens in PHP. (Also jwt bearer token)
Use composer to manage your dependencies and download PHP-JWT:
composer require firebase/php-jwt
- Install the dependencies with Composer
- Run Encode:
$ php encode.php
- Run Decode:
$ php decode.php
JSON Web Tokens are an open, industry standard RFC 7519 method for representing claims securely between two parties.
JSON Web Token (JWT) is a compact, URL-safe means of representing claims to be transferred between two parties.
The claims in a JWT are encoded as a JSON object that is used as the payload of a JSON Web Signature (JWS) structure or as the plaintext of a JSON Web Encryption (JWE) structure, enabling the claims to be digitally signed or integrity protected with a Message Authentication Code (MAC) and/or encrypted.
- https://jwt.io/
- https://github.com/firebase/php-jwt
- https://github.com/cdoco/php-jwt
- https://tools.ietf.org/html/rfc7519
If you are interested you may be interested to read more:
- https://github.com/nov/jose-php
- https://github.com/Spomky-Labs/jose
- https://www.example-code.com/phpExt/jwe.asp
I prepared this sample for Mr. Kambiz. I hope it helps you too. Thanks to him for making me write this code.
My nickname is Max, Programming language developer, Full-stack programmer. I love computer scientists, researchers, and compilers. (Max Base)
A team includes some programmer, developer, designer, researcher(s) especially Max Base.