PHPackages                             vjolenz/php-otp - 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. vjolenz/php-otp

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

vjolenz/php-otp
===============

PHP OTP (One Time Password) implementation

v1.0.0(8y ago)08201PHPPHP ^7.2

Since Dec 20Pushed 8y ago1 watchersCompare

[ Source](https://github.com/vjolenz/php-otp)[ Packagist](https://packagist.org/packages/vjolenz/php-otp)[ RSS](/packages/vjolenz-php-otp/feed)WikiDiscussions master Synced today

READMEChangelog (2)Dependencies (2)Versions (4)Used By (0)

PHP OTP (One Time Password) Implementation
==========================================

[](#php-otp-one-time-password-implementation)

[![Build Status](https://camo.githubusercontent.com/4eb05b8c3055eaa046cd8cacbc9ff3893929ba6c201914ecda5c14821614356a/68747470733a2f2f7472617669732d63692e6f72672f766a6f6c656e7a2f7068702d6f74702e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/vjolenz/php-otp)[![StyleCI](https://camo.githubusercontent.com/10db6a890a0b1069562d3cc0798ad47c20cf6a05d9057e8ed92c5312b91958da/68747470733a2f2f7374796c6563692e696f2f7265706f732f3131333530393432372f736869656c643f6272616e63683d6d6173746572)](https://styleci.io/repos/113509427)

A PHP library to generate and verify one-time passwords. It is compatible with [HOTP](http://tools.ietf.org/html/rfc4226)and [TOTP](http://tools.ietf.org/html/rfc6238).

Prerequisites
-------------

[](#prerequisites)

This library needs at least `PHP 7.0`.

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

[](#installation)

You can install via composer.

```
$ composer require vjolenz/php-otp
```

HOTP Usage
----------

[](#hotp-usage)

Generation and verification requires a moving factor that changes on per use. You can use a login counter as moving factor.

##### Create Password

[](#create-password)

```
   $user = User::find(1);

   $authenticator = new \vjolenz\OtpAuth\HotpAuthenticator();
   $authenticator->setSecret('12345678901234567890'); // Default: null
   $authenticator->setAlgorithm('SHA256'); // Default: SHA1
   $authenticator->setWindowSize(3); // Default: 1
   $authenticator->setPasswordLength(9); // Default: 6

   $password = $authenticator->generatePassword($user->getLoginCounter());

   $user->advanceLoginCounter();
```

##### Verify Password

[](#verify-password)

```
   $user = User::find(1);

   $authenticator = new \vjolenz\OtpAuth\HotpAuthenticator();
   $authenticator->setSecret('12345678901234567890'); // Default: null
   $authenticator->setAlgorithm('SHA256'); // Default: SHA1
   $authenticator->setWindowSize(3); // Default: 1
   $authenticator->setPasswordLength(9); // Default: 6

   $authenticator->verifyPassword($password, $user->getLoginCounter());
```

TOTP Usage
----------

[](#totp-usage)

Unlike HOTP generation and verification, you don't need a moving factor since the current timestamp is used for these operations

##### Create Password

[](#create-password-1)

```
   $authenticator = new \vjolenz\OtpAuth\TotpAuthenticator();
   $authenticator->setSecret('12345678901234567890'); // Default: null
   $authenticator->setAlgorithm('SHA256'); // Default: SHA1
   $authenticator->setWindowSize(3); // Default: 1
   $authenticator->setPasswordLength(9); // Default: 6
   $authenticator->setInterval(60); // Default: 30

   $password = $authenticator->generatePassword();
```

##### Verify Password

[](#verify-password-1)

```
   $authenticator = new \vjolenz\OtpAuth\TotpAuthenticator();
   $authenticator->setSecret('12345678901234567890'); // Default: null
   $authenticator->setAlgorithm('SHA256'); // Default: SHA1
   $authenticator->setWindowSize(3); // Default: 1
   $authenticator->setPasswordLength(9); // Default: 6
   $authenticator->setInterval(60); // Default: 30

   $authenticator->verifyPassword($password);
```

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.MD) for more information.

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity60

Established project with proven stability

 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

Every ~0 days

Total

2

Last Release

3113d ago

Major Versions

v0.1.0 → v1.0.02017-12-20

PHP version history (2 changes)v0.1.0PHP ^7.0

v1.0.0PHP ^7.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/168c2fcad44e57cbcff8d6f77496a194710755d524004dbe72fa7461d33d9720?d=identicon)[vjolenz](/maintainers/vjolenz)

---

Top Contributors

[![0xK4d1r](https://avatars.githubusercontent.com/u/15370532?v=4)](https://github.com/0xK4d1r "0xK4d1r (19 commits)")

---

Tags

hotpotpotpauthphp-otptotp

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/vjolenz-php-otp/health.svg)

```
[![Health](https://phpackages.com/badges/vjolenz-php-otp/health.svg)](https://phpackages.com/packages/vjolenz-php-otp)
```

###  Alternatives

[kartik-v/yii2-password

Useful password strength validation utilities for Yii Framework 2.0

761.2M17](/packages/kartik-v-yii2-password)

PHPackages © 2026

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