PHPackages                             hosseinhezami/totp-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. hosseinhezami/totp-authenticator

ActiveLibrary

hosseinhezami/totp-authenticator
================================

A PHP library for Time-based One-Time Password (TOTP) authentication

v1.0.0(8mo ago)323.3k↓47.9%1[1 issues](https://github.com/hosseinhezami/totp-authenticator/issues)MITPHPPHP &gt;=7.4

Since Sep 5Pushed 8mo ago2 watchersCompare

[ Source](https://github.com/hosseinhezami/totp-authenticator)[ Packagist](https://packagist.org/packages/hosseinhezami/totp-authenticator)[ RSS](/packages/hosseinhezami-totp-authenticator/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

TOTP Authenticator
==================

[](#totp-authenticator)

A PHP library for **Time-based One-Time Password (TOTP)** authentication, compatible with Google Authenticator and other 2FA apps.

- Author: Hossein Hezami, [@HosseinHezami](https://x.com/HosseinHezami)

---

Installation
------------

[](#installation)

```
composer require hosseinhezami/totp-authenticator
```

Usage
-----

[](#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
-------------------

[](#example-qr-code-url)

```
https://quickchart.io/qr?text=otpauth://totp/user@example.com?secret=XXXX&issuer=MyApp
```

Features
--------

[](#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

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance59

Moderate activity, may be stable

Popularity32

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity35

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

256d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/38b7c34a3bb546140c926613060af92984bc184c8731e1cf9aaea704ca88a685?d=identicon)[hosseinhezami](/maintainers/hosseinhezami)

---

Top Contributors

[![hosseinhezami](https://avatars.githubusercontent.com/u/8210576?v=4)](https://github.com/hosseinhezami "hosseinhezami (1 commits)")

### Embed Badge

![Health badge](/badges/hosseinhezami-totp-authenticator/health.svg)

```
[![Health](https://phpackages.com/badges/hosseinhezami-totp-authenticator/health.svg)](https://phpackages.com/packages/hosseinhezami-totp-authenticator)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
