PHPackages                             danterobles/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. [Security](/categories/security)
4. /
5. danterobles/totp-authenticator

ActiveLibrary[Security](/categories/security)

danterobles/totp-authenticator
==============================

A lightweight and secure PHP class for implementing TOTP two-factor authentication, compatible with Google Authenticator, Authy, and more.

v1.0.1(1y ago)171[1 PRs](https://github.com/danterobles/TOTPAuthenticator/pulls)MITPHPPHP &gt;=7.0

Since Mar 31Pushed 1y ago1 watchersCompare

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

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

TOTP Authenticator for PHP
==========================

[](#totp-authenticator-for-php)

Overview
--------

[](#overview)

`TOTPAuthenticator` is a PHP class that implements Time-based One-Time Password (TOTP) authentication according to [RFC 6238](https://datatracker.ietf.org/doc/html/rfc6238). It provides a secure way to implement two-factor authentication (2FA) in your PHP applications, compatible with popular authenticator apps like Google Authenticator, Microsoft Authenticator, and Authy.

Features
--------

[](#features)

- Generate secure random secrets for TOTP authentication
- Create and validate time-based one-time passwords
- Generate QR code URLs for easy setup with authenticator apps
- Customizable code length and time step
- Built-in Base32 encoding/decoding
- Compatible with all standard TOTP authenticator applications

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

[](#installation)

### Raw PHP

[](#raw-php)

1. Simply include the `TOTPAuthenticator.php` file in your project:

```
require_once 'path/to/TOTPAuthenticator.php';
```

### Laravel

[](#laravel)

1. Create a new directory in your Laravel project:

```
mkdir -p app/Services/Auth
```

2. Copy the `TOTPAuthenticator.php` file to this directory and update the namespace:

```
