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

ActiveLibrary

abmmhasan/otp
=============

Simple &amp; Secure Generic OTP, OCRA (RFC6287), TOTP (RFC6238) &amp; HOTP (RFC4226) solution!

5.02.2(4d ago)1319MITPHPPHP &gt;=8.4CI passing

Since Nov 8Pushed 4d ago1 watchersCompare

[ Source](https://github.com/infocyph/OTP)[ Packagist](https://packagist.org/packages/abmmhasan/otp)[ RSS](/packages/abmmhasan-otp/feed)WikiDiscussions main Synced today

READMEChangelog (10)Dependencies (12)Versions (22)Used By (0)

OTP
===

[](#otp)

[![Security & Standards](https://github.com/infocyph/OTP/actions/workflows/security-standards.yml/badge.svg)](https://github.com/infocyph/OTP/actions/workflows/security-standards.yml)[![Packagist Downloads](https://camo.githubusercontent.com/0d0cb8d43efc407ebcc944221b0041b7264c190bb9f2b5070fe90e67a297ae80/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f696e666f637970682f4f54503f636f6c6f723d677265656e266c696e6b3d68747470732533412532462532467061636b61676973742e6f72672532467061636b61676573253246696e666f637970682532464f5450)](https://camo.githubusercontent.com/0d0cb8d43efc407ebcc944221b0041b7264c190bb9f2b5070fe90e67a297ae80/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f696e666f637970682f4f54503f636f6c6f723d677265656e266c696e6b3d68747470732533412532462532467061636b61676973742e6f72672532467061636b61676573253246696e666f637970682532464f5450)[![License: MIT](https://camo.githubusercontent.com/784362b26e4b3546254f1893e778ba64616e362bd6ac791991d2c9e880a3a64e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d677265656e2e737667)](https://opensource.org/licenses/MIT)[![Packagist Version](https://camo.githubusercontent.com/1cfb5b614286a32713c4f51cc590b9dc017637c36be782761cf10800bd98ac29/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f696e666f637970682f4f5450)](https://camo.githubusercontent.com/1cfb5b614286a32713c4f51cc590b9dc017637c36be782761cf10800bd98ac29/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f696e666f637970682f4f5450)[![Packagist PHP Version](https://camo.githubusercontent.com/270df142cc07850a95e0bdd8e6bf612addb761465acc8dcda462ce2e46bb6e4f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f696e666f637970682f4f54502f706870)](https://camo.githubusercontent.com/270df142cc07850a95e0bdd8e6bf612addb761465acc8dcda462ce2e46bb6e4f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f696e666f637970682f4f54502f706870)[![GitHub Code Size](https://camo.githubusercontent.com/670bfcbf44e70bd100b7d66bcd4bbf5e52a0361925b554604fdf5003ff740013/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c616e6775616765732f636f64652d73697a652f696e666f637970682f4f5450)](https://camo.githubusercontent.com/670bfcbf44e70bd100b7d66bcd4bbf5e52a0361925b554604fdf5003ff740013/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c616e6775616765732f636f64652d73697a652f696e666f637970682f4f5450)[![Documentation](https://camo.githubusercontent.com/23aad7f3eef5efef08a7efddf4c07b2e0f7d505360fbd7b4fe302362b7d274d2/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f446f63756d656e746174696f6e2d4f54502d626c75653f6c6f676f3d72656164746865646f6373266c6f676f436f6c6f723d7768697465)](https://docs.infocyph.com/projects/OTP/)

Standalone OTP and MFA primitives for PHP.

Supports:

- Generic OTP with PSR-6 storage
- TOTP (RFC6238)
- HOTP (RFC4226)
- OCRA (RFC6287)
- Recovery / backup codes
- `otpauth://` generation and parsing
- Replay-protection contracts and in-memory stores

Requirements
------------

[](#requirements)

- PHP 8.4+

Version Compatibility
---------------------

[](#version-compatibility)

OTP Library LinePHP Requirement`5.x``>=8.4``4.x``>=8.2``3.x``>=8.2``2.x``>=8.0``1.x``>=7.1`Use a matching major line when your runtime is pinned to an older PHP version.

Project Policies
----------------

[](#project-policies)

- Security reporting: [SECURITY.md](SECURITY.md)
- Community standards: [CODE\_OF\_CONDUCT.md](CODE_OF_CONDUCT.md)

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

[](#installation)

```
composer require infocyph/otp
```

Highlights
----------

[](#highlights)

- Base32 secret generation, normalization, and validation
- Safer provisioning URI and label handling
- SVG QR rendering plus raw payload/URI access
- Rich verification results where needed, simple bool APIs where preferred
- Configurable TOTP drift windows
- HOTP look-ahead resynchronization
- Replay protection contracts for TOTP, HOTP, and OCRA
- One-time recovery codes with hashed storage

Quick Start
-----------

[](#quick-start)

### TOTP

[](#totp)

```
