PHP code example of jdr / jws-ecdsa

1. Go to this page and download the library: Download jdr/jws-ecdsa 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/ */

    

jdr / jws-ecdsa example snippets


use Lcobucci\JWT\Builder;
use Lcobucci\JWT\Signer\Key;
use JDR\JWS\ECDSA\ES256;

$signer = new ES256();

$privateKey = new Key('file://...');

$token = (new Builder())
    ->setIssuedAt(time())
    ->setExpiration(time() + 3600)
    // ... Set additional claims
    ->sign($signer, $privateKey)
    ->getToken();

$publicKey = new Key('file://...');

$token->verify($signer, $publicKey);