PHPackages                             wccplatform/otphp - 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. wccplatform/otphp

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

wccplatform/otphp
=================

A PHP library for generating one time passwords according to RFC 4226 (HOTP Algorithm) and the RFC 6238 (TOTP Algorithm) and compatible with Google Authenticator

v9.1.0(8y ago)0164MITPHPPHP ^7.1

Since Feb 24Pushed 7y agoCompare

[ Source](https://github.com/wccplatform/otphp)[ Packagist](https://packagist.org/packages/wccplatform/otphp)[ Docs](https://github.com/Spomky-Labs/otphp)[ RSS](/packages/wccplatform-otphp/feed)WikiDiscussions v9.0 Synced 3d ago

READMEChangelogDependencies (4)Versions (42)Used By (0)

TOTP / HOTP library in PHP
==========================

[](#totp--hotp-library-in-php)

Help me out for a couple of 🍻!

[![Beerpay](https://camo.githubusercontent.com/4e31974edf8cbf4252214f7dcf56d9aed6169751689ff6f3d82299a922a3e458/68747470733a2f2f626565727061792e696f2f53706f6d6b792d4c6162732f6f747068702f62616467652e7376673f7374796c653d626565722d737175617265)](https://beerpay.io/Spomky-Labs/otphp) [![Beerpay](https://camo.githubusercontent.com/ff969b61a2e984e8b07e611262b2da07c2a32b35d7413c9aaea49e3af6cb004d/68747470733a2f2f626565727061792e696f2f53706f6d6b792d4c6162732f6f747068702f6d616b652d776973682e7376673f7374796c653d666c61742d737175617265)](https://beerpay.io/Spomky-Labs/otphp?focus=wish)

---

[![Scrutinizer Code Quality](https://camo.githubusercontent.com/5ccf37b63d34656905f6d0a398d093d071d84bbac3656f1fa0cd04245429f35a/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f53706f6d6b792d4c6162732f6f747068702f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Spomky-Labs/otphp/?branch=master)[![Coverage Status](https://camo.githubusercontent.com/7cb4a6d4edfbd88c5707c5ef2f3b014595e7a285b4c8468bb474d8cf749c2d7f/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f53706f6d6b792d4c6162732f6f747068702f62616467652e7376673f6272616e63683d6d617374657226736572766963653d676974687562)](https://coveralls.io/github/Spomky-Labs/otphp?branch=master)

[![Build Status](https://camo.githubusercontent.com/3c1ea914c5257b8640acf7356d31a06c87b33ee7ef39db4498221debab023317/68747470733a2f2f7472617669732d63692e6f72672f53706f6d6b792d4c6162732f6f747068702e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Spomky-Labs/otphp)[![PHP 7 ready](https://camo.githubusercontent.com/78e8acda26949e31a7086cfe342e9270e5b033ac1ff821f81673f5d68f59829a/687474703a2f2f7068703772656164792e74696d6573706c696e7465722e63682f53706f6d6b792d4c6162732f6f747068702f62616467652e737667)](https://travis-ci.org/Spomky-Labs/otphp)

[![SensioLabsInsight](https://camo.githubusercontent.com/7b783fa0607acebf785d97805c277821fcf3861d59221843d96822a73a460fde/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f34396535393235642d306464382d346238392d613231352d3565623333623464393664392f6269672e706e67)](https://insight.sensiolabs.com/projects/49e5925d-0dd8-4b89-a215-5eb33b4d96d9)

[![Latest Stable Version](https://camo.githubusercontent.com/c55ac4699452b2919e4cfcc8175a4e8efc802cb3521426e9091d14f917a918a1/68747470733a2f2f706f7365722e707567782e6f72672f73706f6d6b792d6c6162732f6f747068702f762f737461626c652e706e67)](https://packagist.org/packages/spomky-labs/otphp) [![Total Downloads](https://camo.githubusercontent.com/951788b8d4efe1851090ce79da240c41699ec8a8cc7e955b7fdf73052baa5414/68747470733a2f2f706f7365722e707567782e6f72672f73706f6d6b792d6c6162732f6f747068702f646f776e6c6f6164732e706e67)](https://packagist.org/packages/spomky-labs/otphp) [![Latest Unstable Version](https://camo.githubusercontent.com/6c0b26e3f444867f987569cff21f5f33b2e7eed090a433ea39660bd8abad3239/68747470733a2f2f706f7365722e707567782e6f72672f73706f6d6b792d6c6162732f6f747068702f762f756e737461626c652e706e67)](https://packagist.org/packages/spomky-labs/otphp) [![License](https://camo.githubusercontent.com/9a4149052c508a6bc4792a9a6a13d263a1e29944fdfb223a50ac48038c3f2bd6/68747470733a2f2f706f7365722e707567782e6f72672f73706f6d6b792d6c6162732f6f747068702f6c6963656e73652e706e67)](https://packagist.org/packages/spomky-labs/otphp)

A php library for generating one-time passwords according to [RFC 4226](http://tools.ietf.org/html/rfc4226) (HOTP Algorithm) and [RFC 6238](http://tools.ietf.org/html/rfc6238) (TOTP Algorithm)

This library is compatible with Google Authenticator apps available for Android and iPhone. It is also compatible with other applications such as [FreeOTP](https://play.google.com/store/apps/details?id=org.fedorahosted.freeotp) for example.

The Release Process
-------------------

[](#the-release-process)

The release process [is described here](doc/Release.md).

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

[](#prerequisites)

This library needs at least `PHP 7.1`. It has been successfully tested using `PHP 7.1` and nightly branch.

For older PHP versions support, please use release [`8.3.x`](https://github.com/Spomky-Labs/otphp/tree/v8.3.0) of this library.

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

[](#installation)

The preferred way to install this library is to rely on Composer:

```
composer require spomky-labs/otphp
```

By default, documentation and test environment are excluded. If you want to test the library or get the documentation, please add `--prefer-source` option:

```
composer require spomky-labs/otphp --prefer-source
```

TOTP or HOTP?
-------------

[](#totp-or-hotp)

This library supports both `TOTP` and `HOTP`.

`TOTP` is a time based one-time password. It lives only for a few seconds (the `period`). You just have to be sure that the clock of your server and your device are synchronized. **This is the most common OTP**.

`HOTP` is a counter based one-time password. Every time a password is used, the counter is updated. You have to verify that the server and the device are synchronized.

How to use
----------

[](#how-to-use)

To create an OTP object, just use the static `create` method. Your object will be able to generate passwords:

```
