1. Go to this page and download the library: Download namshi/jose library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
namshi / jose example snippets
$jws = new JWS(array('alg' => 'RS256'), 'SecLib');
php
use Namshi\JOSE\SimpleJWS;
$jws = SimpleJWS::load($_COOKIE['identity']);
$public_key = openssl_pkey_get_public("/path/to/public.key");
// verify that the token is valid and had the same values
// you emitted before while setting it as a cookie
if ($jws->isValid($public_key, 'RS256')) {
$payload = $jws->getPayload();
echo sprintf("Hey, my JS app just did an action authenticated as user #%s", $payload['uid']);
}
php
$date = new DateTime('tomorrow');
$this->jws = new SimpleJWS(array('alg' => 'RS256'));
$this->jws->setPayload(array(
'exp' => $date->format('U'),
));