定制 haikiri/simple-php-totp 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

haikiri/simple-php-totp

最新稳定版本:1.2.1

Composer 安装命令:

composer require haikiri/simple-php-totp

包简介

Lightweight PHP TOTP (RFC 6238) and Base32 (RFC 4648) generation/decoding for 2FA authentication

README 文档

README

Language: English | Русский

A lightweight and vanilla PHP library for generating TOTP (2FA) codes.

Compatibility

  • PHP 7+ && PHP 8+
  • Tests: phpunit/phpunit (^9.6 || ^8.5 || ^6.5)

Installation

composer require haikiri/simple-php-totp

Usage example

<?php

require __DIR__ . '/vendor/autoload.php';

use Haikiri\SimplePhpTotp\TOTP;

# Generate a secret for storing in the DB.
$secret = TOTP::generateSecret();

# Generate a 6-digit OTP code based on the secret.
$code = TOTP::generate($secret);

echo $secret . PHP_EOL; # Secret for the user. (needs be stored in the user's DB)
echo $code . PHP_EOL; # TOTP-code with which we should compare the code provided by the user from the 2FA-app.

Get OTPAuth URL

<?php

use Haikiri\SimplePhpTotp\TOTP;

$url = TOTP::getTotpUrl(
    'GJQTCOBSMI2TGZTD', # OTP-secret (Base32)
    'user@example.com', # Username / client identifier
    'My Service' # Issuer / organization name
);

echo $url . PHP_EOL; # otpauth://totp/My%20Service:user%40example.com?secret=GJQTCOBSMI2TGZTD&issuer=My%20Service

统计信息

  • 总下载量: 235
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-02-10

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固