attla / data-token
将一切转换为令牌:随机或可预测。
dev-main
2022-08-14 17:37 UTC
Requires
- php: >=7.2.5
- attla/pincryp: dev-main
- hisorange/browser-detect: ^4.5.2
- nesbot/carbon: ^2.31
README
🪅 将一切转换为令牌:随机或可预测。
安装
composer require attla/data-token
使用
创建和管理令牌
use Attla\DataToken\Facade as DataToken; // Create with facade $token = DataToken::secrete('your secret phrase'); // Set the issuer claim $token->iss(); // Set the expiration in minutes $token->exp(120); // Set payload of the token $token->payload($model); // Set the browser identifier on token $token->bwr(); // Set user IP on the token $token->ip(); // Get the token $tokenEncoded = $token->encode();
解码令牌
// Get token value as associative array $tokenValue = DataToken::decode($tokenEncoded, true); // Aliases for decode a token $tokenValue = DataToken::fromString($tokenEncoded); $tokenValue = DataToken::parseString($tokenEncoded); $tokenValue = DataToken::parse($tokenEncoded);
其他创建令牌的方法
// Make a unique token from anything $id = DataToken::id(123); // Make always the same token $sid = DataToken::sid(123); // Make a strong token $sign = DataToken::sign(123);
消息方法列表
许可
本软件包采用 MIT 许可协议授权,版权所有 © Octha。