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

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

texdc/totp
==========

Simple TOTP (RFC 6238)

v2.0.2(8y ago)1354CC-BY-NC-SA-4.0PHPPHP ^7.1

Since Jun 15Pushed 8y ago1 watchersCompare

[ Source](https://github.com/texdc/totp)[ Packagist](https://packagist.org/packages/texdc/totp)[ RSS](/packages/texdc-totp/feed)WikiDiscussions master Synced yesterday

READMEChangelog (5)Dependencies (6)Versions (7)Used By (0)

TOTP (RFC 6238)
===============

[](#totp-rfc-6238)

TOTP is a simple, compact and bare-bones PHP class for calculating [TOTP](https://en.wikipedia.org/wiki/Time-based_One-time_Password_Algorithm) tokens using the SHA1 default, commonly used for two-factor authentication in mobile apps such as Google Authenticator. It comprises three public methods of which only one is necessary to call to get a token.

Usage
-----

[](#usage)

Simply call `$totp->getOTP( $secret [, $digits = 6 [, $period = 30 [, $offset = null ]]] )`which returns a string holding the authentication token.

The other two functions are meant to be convenient utilities:

`$totp->genSecret( [ $length = 24 ] )` generates a TOTP-compatible pseudorandom secret in Base32 ASCII, returning a string holding the random secret.

`$totp->genURI( $account, $secret [, $digits = null [, $period = null [, $issuer = '' ]]] )`returns a string holding an `otpauth://` style URI providing the supplied parameters, which can be embedded in a QR code image.

> NOTE: All arguments are validated and every method may throw an `Assert\AssertionFailedException` detailing the error.

License
-------

[](#license)

TOTP is released under the [Creative Commons BY-NC-SA 4.0 license](http://creativecommons.org/licenses/by-nc-sa/4.0/).

Portions Copyright (c) 2014 [Robin Leffman](https://github.com/stolendata). The original source is [available on github](https://github.com/stolendata/totp).

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 65.7% 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

Every ~154 days

Total

5

Last Release

3051d ago

Major Versions

v1.0.1 → v2.0.02017-10-15

PHP version history (3 changes)v1.0.0PHP ^5.6 || ^7.0

v2.0.0PHP ^7.0

v2.0.1PHP ^7.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/b00c18dc19530c6fa5cc0cafc053dd9377dace10c90d73182b79f8499d2c26d1?d=identicon)[texdc](/maintainers/texdc)

---

Top Contributors

[![texdc](https://avatars.githubusercontent.com/u/1590605?v=4)](https://github.com/texdc "texdc (23 commits)")[![stolendata](https://avatars.githubusercontent.com/u/1296914?v=4)](https://github.com/stolendata "stolendata (11 commits)")[![benaryorg](https://avatars.githubusercontent.com/u/6145260?v=4)](https://github.com/benaryorg "benaryorg (1 commits)")

---

Tags

2fa2factorauthenticationmfaphptotptotp2faauthenticateMFA2factor

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

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

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

###  Alternatives

[paragonie/multi-factor

Vendor-agnostic two-factor authentication library

142197.5k2](/packages/paragonie-multi-factor)[chillerlan/php-authenticator

A generator for counter- and time based 2-factor authentication codes (Google Authenticator). PHP 8.2+

56127.6k3](/packages/chillerlan-php-authenticator)[ellaisys/aws-cognito

AWS Cognito package that allows Auth and other related features using the AWS SDK for PHP

121242.9k1](/packages/ellaisys-aws-cognito)[scheb/2fa-totp

Extends scheb/2fa-bundle with two-factor authentication using TOTP

283.1M45](/packages/scheb-2fa-totp)[2amigos/2fa-library

2 Factor Authentication (2FA) library

34386.3k7](/packages/2amigos-2fa-library)[jiripudil/otp

Library that generates and verifies one-time passwords.

2827.4k1](/packages/jiripudil-otp)

PHPackages © 2026

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