承接 hosseinhezami/totp-authenticator 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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.

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

GitHub 信息

  • Stars: 30
  • Watchers: 2
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-09-05