texdc / totp
简单的TOTP (RFC 6238)
v2.0.2
2018-02-22 05:27 UTC
Requires
- php: ^7.1
- texdc/guard: @stable
Requires (Dev)
- phpmd/phpmd: @stable
- phpmetrics/phpmetrics: @stable
- phpunit/phpunit: @stable
- satooshi/php-coveralls: @stable
- squizlabs/php_codesniffer: @stable
Suggests
- chillerlan/php-qrcode: For generating QR code images
This package is not auto-updated.
Last update: 2024-09-14 18:09:49 UTC
README
TOTP是一个简单、紧凑且基础PHP类,用于计算TOTP令牌(使用SHA1默认),通常用于移动应用(如Google Authenticator)中的双因素认证。它包含三个公共方法,其中只有一个方法是必需的,用于获取令牌。
用法
只需调用 $totp->getOTP( $secret [, $digits = 6 [, $period = 30 [, $offset = null ]]] )
,它返回包含认证令牌的字符串。
其他两个函数是方便的工具函数
$totp->genSecret( [ $length = 24 ] )
生成一个TOTP兼容的伪随机密钥,以Base32 ASCII形式返回,返回包含随机密钥的字符串。
$totp->genURI( $account, $secret [, $digits = null [, $period = null [, $issuer = '' ]]] )
返回一个包含所提供参数的字符串,以otpauth://
风格的URI形式,可以嵌入到QR码图像中。
注意:所有参数都会进行验证,每个方法都可能抛出
Assert\AssertionFailedException
异常,详细说明错误。
许可
TOTP是在Creative Commons BY-NC-SA 4.0许可下发布的。
部分版权(c)2014 Robin Leffman。原始源代码可在GitHub上找到。