jdr/jws-ecdsa

lcobucci/jwt的ECDSA签名者

0.4.1 2017-12-09 16:31 UTC

This package is auto-updated.

Last update: 2024-09-12 02:50:05 UTC


README

Latest Version on Packagist Software License Build Status Total Downloads

lcobucci/jwt的ECDSA签名者。

创建此库是为了支持mdanter/ecc 0.4.x与lcobucci/jwt 3.x的结合,一旦lcobucci/jwt本身提供对mdanter/ecc库此版本的兼容性支持,将会被弃用。

安装

使用Composer安装库

composer require jdr/jws-ecdsa

用法

此库提供的签名者是lcobucci/jwt提供的签名者的直接替换品。

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);

致谢

许可证

MIT许可证(MIT)。请参阅许可证文件以获取更多信息。