hosseinhezami/totp-authenticator
最新稳定版本:v1.0.0
Composer 安装命令:
composer require hosseinhezami/totp-authenticator
包简介
A PHP library for Time-based One-Time Password (TOTP) authentication
README 文档
README
A PHP library for Time-based One-Time Password (TOTP) authentication, compatible with Google Authenticator and other 2FA apps.
- Author: Hossein Hezami, @HosseinHezami
Installation
composer require hosseinhezami/totp-authenticator
Usage
use HosseinHezami\TotpAuthenticator\Authenticator; // Generate a new secret key $secret = Authenticator::createSecret(); // Generate a TOTP code $code = Authenticator::generateCode($secret); // Verify the code $isValid = Authenticator::verifyCode($secret, $code); var_dump($isValid); // true // Generate a QR code URL for Google Authenticator $qrCodeUrl = Authenticator::generateQrCodeUrl("user@example.com", $secret, "MyApp"); echo $qrCodeUrl;
Example QR Code URL
https://quickchart.io/qr?text=otpauth://totp/user@example.com?secret=XXXX&issuer=MyApp
Features
- Generate cryptographically secure secrets
- Generate TOTP codes (RFC 6238)
- Verify codes with time drift tolerance
- Generate QR code URLs for Google Authenticator and similar apps
- Timing-safe comparison to prevent timing attacks
统计信息
- 总下载量: 2.08k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 31
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-09-05