webiik/token
Composer 安装命令:
composer require webiik/token
包简介
The Token generates and compares tokens.
关键字:
README 文档
README
Token
The Token generates and compares tokens.
Installation
composer require webiik/token
Example
$token = new \Webiik\Token\Token(); $secureToken = $token->generate(); if ($token->compare('vuefjsdfk', $secureToken)) { // Tokens are equal }
Generating
generate
generate($strength = 16): string
generate() returns safe token. By default the token is 32 characters long. It throws Exception when it was not possible to generate safe token.
try { $token->generate(); } catch (Exception $exception) { // Unable to generate strong token }
generateCheap
generateCheap($length = 32): string
generateCheap() returns cheap token. By default the token is 32 characters long. Cheap token is not safe, but is faster to generate.
$token->generateCheap();
Comparison
compare
compare(string $original, string $imprint): bool
compare() Compares two strings using the same time whether they're equal or not - Timing attack safe string comparison.
$token->compare('known-string', 'user-string');
Timing-attack safe comparison is slower than regular comparison.
Resources
统计信息
- 总下载量: 169
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 4
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-03-04