jakobo / hotp-php
HOTP 简化了 PHP 认证中的单次密码系统
v2.0.0
2020-12-28 03:29 UTC
Requires
- php: >=7.2
Requires (Dev)
- ockcyp/covers-validator: 1.3.3
- php-parallel-lint/php-console-highlighter: 0.5
- php-parallel-lint/php-parallel-lint: 1.2.0
- phpunit/phpunit: ^8.5.13||^9.5.0
This package is not auto-updated.
Last update: 2024-09-10 23:05:01 UTC
README
什么是 HOTP: HOTP 是一个类,用于简化 PHP 认证中的单次密码系统。HOTP/TOTP 算法已经存在一段时间了,因此这是一个满足测试向量要求的简单类。
HOTP/TOTP 与什么兼容:它已经通过测试向量测试,并且我已经验证了时间同步哈希与以下内容相符
- Android:Mobile-OTP
- iPhone:OATH Token
为什么我会使用这个:谁不喜欢一个简单的 HMAC 基于的单次密码类呢?这是一个很好的额外安全层(创建双因素认证),并且它非常快速。
好吧,你已经说服了我。给我一些文档:
use jakobo\HOTP\HOTP; // event based $result = HOTP::generateByCounter( $key, $counter ); // time based within a "window" of time $result = HOTP::generateByTime( $key, $window ); // same as generateByTime, but for $min windows before and $max windows after $result = HOTP::generateByTimeWindow( $key, $window, $min, $max );
使用 $result
,你可以做各种有趣的事情...
$result->toString(); $result->toHex(); $result->toDec(); // how many digits in your OTP? $result->toHotp( $length );