soatok / wp-paseto
支持PHP 5.6+(适用于WordPress项目)的PASETO v4.local实现
v0.2.0
2024-04-21 01:33 UTC
Requires
- php: >= 5.6
- ext-json: *
- paragonie/sodium_compat: ^1|^2
Requires (Dev)
- phpunit/phpunit: >= 5
- vimeo/psalm: >= 1
This package is auto-updated.
Last update: 2024-09-21 02:33:01 UTC
README
要求
- PHP 5.6或更高版本
推荐
- PHP 7.2或更高版本
- Sodium扩展
支持密钥轮换。仅实现v4.local。
!
安装
composer require soatok/wp-paseto
使用
向构造函数提供一个映射到十六进制编码密钥的键字符串数组。然后您可以使用encode()
和decode()
来编码和解析包含任意声明的数组。
<?php // Define your keys $encoder = new WP_Paseto(( 'key-id-1' => 'hex-encoded 256-bit (32 byte) random key goes here', 'key-id-2' => 'hex-encoded 256-bit (32 byte) random key goes here', // ... 'key-id-N' =>L 'hex-encoded 256-bit (32 byte) random key goes here' )); // Encode a secret $token = $encoder->encode(array('secret' => 'value goes here')); var_dump($token); /* v4.local.fHvh8jwJauiNMdC0yRZ9xvbCE5cdrNwP4... */ // Decode $claims = $encoder->decode($token);