PHPackages                             yoolo-mine/google-authenticator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. yoolo-mine/google-authenticator

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

yoolo-mine/google-authenticator
===============================

Google Authenticator 2FA library (forked and optimized from PHPGangsta).

v1.0.0(10mo ago)00MITPHPPHP &gt;=7.2

Since Aug 26Pushed 10mo agoCompare

[ Source](https://github.com/yoolo-mine/GoogleAuthenticator)[ Packagist](https://packagist.org/packages/yoolo-mine/google-authenticator)[ Docs](https://github.com/yoolo-mine/google-authenticator)[ RSS](/packages/yoolo-mine-google-authenticator/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (3)Used By (0)

Google Authenticator PHP Class / PHP 谷歌身份验证器类
=============================================

[](#google-authenticator-php-class--php-谷歌身份验证器类)

[![License](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](LICENSE)[![PHP Version](https://camo.githubusercontent.com/693d86ace28ed781ac20a7067dbc5ec928caaec2086153f9e036986e4e7b06f6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d2533453d372e322d626c7565)](https://www.php.net/)

A PHP library to interact with Google Authenticator for 2FA.
本 PHP 库用于与 Google Authenticator 移动应用交互，实现双因素认证 (2FA)。

It can generate secrets, generate and verify codes, and provide QR-Code URIs. Implements TOTP according to [RFC6238](https://tools.ietf.org/html/rfc6238).
它可以生成密钥、生成和验证验证码，并提供二维码 URI。遵循 TOTP 标准 [RFC6238](https://tools.ietf.org/html/rfc6238)。

---

Features / 功能
-------------

[](#features--功能)

- Generate and verify **TOTP** codes / 生成和验证 TOTP 验证码
- QR-Code URI generation / 生成二维码 URI
- Customizable code length (default: 6) / 可自定义验证码长度（默认 6 位）
- Compatible with Google Authenticator, Authy, 1Password, etc. / 兼容 Google Authenticator、Authy、1Password 等 2FA 应用
- Includes PHPUnit test cases / 内置 PHPUnit 单元测试

---

Installation / 安装
-----------------

[](#installation--安装)

Use Composer:
使用 Composer 安装：

```
composer require yoolo-mine/google-authenticator
```

QR Code Example / 二维码示例
-----------------------

[](#qr-code-example--二维码示例)

You can generate a QR Code for your secret and display it in HTML using Google Chart API: 可以使用 Google Chart API 为密钥生成二维码，并在 HTML 中显示：

```
