PHPackages                             neto737/googleauthenticator - 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. neto737/googleauthenticator

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

neto737/googleauthenticator
===========================

Google Authenticator 2-factor authentication

1.0.0(2y ago)025BSD-2-ClausePHPPHP &gt;=8.1

Since Jul 2Pushed 2y agoCompare

[ Source](https://github.com/neto737/GoogleAuthenticator)[ Packagist](https://packagist.org/packages/neto737/googleauthenticator)[ Fund](https://liberapay.com/neto737)[ RSS](/packages/neto737-googleauthenticator/feed)WikiDiscussions main Synced yesterday

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

Google Authenticator PHP class
==============================

[](#google-authenticator-php-class)

- Copyright (c) 2012-2016,
- Author: Michael Kliewe, [@PHPGangsta](http://twitter.com/PHPGangsta) and [contributors](https://github.com/PHPGangsta/GoogleAuthenticator/graphs/contributors)
- Licensed under the BSD License.

[![Latest Stable Version](https://camo.githubusercontent.com/e503177dbc28d4bc6b4105ff4ebd0f47afc716e43f21c175e436cb8de20b2bf5/68747470733a2f2f706f7365722e707567782e6f72672f6e65746f3733372f676f6f676c6561757468656e74696361746f722f76657273696f6e3f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/neto737/googleauthenticator)[![Total Downloads](https://camo.githubusercontent.com/7b01b85da612985a53f6e414cced76c0ee1cde21336840748a3e1664532cf6f7/68747470733a2f2f706f7365722e707567782e6f72672f6e65746f3733372f676f6f676c6561757468656e74696361746f722f646f776e6c6f6164733f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/neto737/googleauthenticator)[![License](https://camo.githubusercontent.com/2890fe8e65c0165299fa7d5be66668a9f9ba4e7739e4ef7b25ca316afe57af2a/68747470733a2f2f706f7365722e707567782e6f72672f6e65746f3733372f676f6f676c6561757468656e74696361746f722f6c6963656e73653f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/neto737/googleauthenticator)[![PHP Version Require](https://camo.githubusercontent.com/d5208bf0ed14a0b8b90bfcdf7dee2b9fee130d76f419980a8dc8cd4e1db2b92f/68747470733a2f2f706f7365722e707567782e6f72672f6e65746f3733372f676f6f676c6561757468656e74696361746f722f726571756972652f7068703f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/neto737/googleauthenticator)[![GitHub Workflow Status](https://camo.githubusercontent.com/05757ff7775973f63df3be316c51ce493e410097461f0dcf9758d9504a63e0b8/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f6e65746f3733372f476f6f676c6541757468656e74696361746f722f504850253230436f6d706f7365723f6c6f676f3d676974687562267374796c653d666f722d7468652d6261646765)](https://github.com/neto737/googleauthenticator)[![Codecov branch](https://camo.githubusercontent.com/842d8c42bab8bd2333c7e2e87ea915634f398012a9b3728bd7851551b736fc3f/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f67682f6e65746f3733372f676f6f676c6561757468656e74696361746f722f6d61696e3f6c6f676f3d636f6465636f76267374796c653d666f722d7468652d626164676526746f6b656e3d33384b504c3942583546)](https://app.codecov.io/gh/neto737/googleauthenticator)

This PHP class can be used to interact with the Google Authenticator mobile app for 2-factor-authentication. This class can generate secrets, generate codes, validate codes and present a QR-Code for scanning the secret. It implements TOTP according to [RFC 6238](https://tools.ietf.org/html/rfc6238)

For a secure installation you have to make sure that used codes cannot be reused (replay-attack). You also need to limit the number of verifications, to fight against brute-force attacks. For example you could limit the amount of verifications to 10 tries within 10 minutes for one IP address (or IPv6 block). It depends on your environment.

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

[](#installation)

- Use [Composer](https://getcomposer.org/doc/01-basic-usage.md) to install the package
- From project root directory execute following

```
$ composer require neto737/GoogleAuthenticator
```

Or if put the following in your `composer.json`:

```
"require": {
    "neto737/GoogleAuthenticator": "~2.0"
}
```

Usage
-----

[](#usage)

See following example:

```
require 'vendor/autoload.php';

$ga = new \neto737\GoogleAuthenticator;

$secret = $ga->createSecret();
echo "Secret is: " . $secret . PHP_EOL . PHP_EOL;

$qrCodeUrl = $ga->getQRCodeGoogleUrl('Blog', $secret);
echo "Google Charts URL for the QR-Code: ".$qrCodeUrl . PHP_EOL . PHP_EOL;

$oneCode = $ga->getCode($secret);
echo "Checking Code '$oneCode' and Secret '$secret': ";

$checkResult = $ga->verifyCode($secret, $oneCode, 2); // 2 = 2*30sec clock tolerance
if ($checkResult) {
    echo 'OK';
} else {
    echo 'FAILED';
}
```

Running the script provides the following output:

```
Secret is: OQB6ZZGYHCPSX4AK

Google Charts URL for the QR-Code: https://www.google.com/chart?chs=200x200&chld=M|0&cht=qr&chl=otpauth://totp/infoATphpgangsta.de%3Fsecret%3DOQB6ZZGYHCPSX4AK

Checking Code '848634' and Secret 'OQB6ZZGYHCPSX4AK': OK

```

Notes
-----

[](#notes)

If you like this script or have some features to add: contact me, visit my blog, fork this project, send pull requests, you know how it works.

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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

Unknown

Total

1

Last Release

732d ago

### Community

Maintainers

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

---

Top Contributors

[![PHPGangsta](https://avatars.githubusercontent.com/u/608408?v=4)](https://github.com/PHPGangsta "PHPGangsta (27 commits)")[![neto737](https://avatars.githubusercontent.com/u/2430438?v=4)](https://github.com/neto737 "neto737 (26 commits)")[![symm](https://avatars.githubusercontent.com/u/69390?v=4)](https://github.com/symm "symm (6 commits)")[![LukaszPiechowiak](https://avatars.githubusercontent.com/u/8948593?v=4)](https://github.com/LukaszPiechowiak "LukaszPiechowiak (4 commits)")[![r--w](https://avatars.githubusercontent.com/u/1191700?v=4)](https://github.com/r--w "r--w (4 commits)")[![Sc00bz](https://avatars.githubusercontent.com/u/2030592?v=4)](https://github.com/Sc00bz "Sc00bz (3 commits)")[![pgampe](https://avatars.githubusercontent.com/u/855238?v=4)](https://github.com/pgampe "pgampe (3 commits)")[![samundra](https://avatars.githubusercontent.com/u/760855?v=4)](https://github.com/samundra "samundra (3 commits)")[![yanniks](https://avatars.githubusercontent.com/u/993397?v=4)](https://github.com/yanniks "yanniks (1 commits)")[![alexandregz](https://avatars.githubusercontent.com/u/1374718?v=4)](https://github.com/alexandregz "alexandregz (1 commits)")[![edwardmp](https://avatars.githubusercontent.com/u/1686739?v=4)](https://github.com/edwardmp "edwardmp (1 commits)")[![leandro-lugaresi](https://avatars.githubusercontent.com/u/858713?v=4)](https://github.com/leandro-lugaresi "leandro-lugaresi (1 commits)")[![vmelnic](https://avatars.githubusercontent.com/u/1056081?v=4)](https://github.com/vmelnic "vmelnic (1 commits)")[![34x](https://avatars.githubusercontent.com/u/60165?v=4)](https://github.com/34x "34x (1 commits)")

---

Tags

totp2fa2 factor authenticator library

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/neto737-googleauthenticator/health.svg)

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

###  Alternatives

[paragonie/multi-factor

Vendor-agnostic two-factor authentication library

142198.6k2](/packages/paragonie-multi-factor)[scheb/2fa-totp

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

293.3M50](/packages/scheb-2fa-totp)[2amigos/2fa-library

2 Factor Authentication (2FA) library

34391.0k7](/packages/2amigos-2fa-library)[chillerlan/php-authenticator

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

58133.8k3](/packages/chillerlan-php-authenticator)[sebastiandevs/simplethenticator

TOTP based on https://github.com/PHPGangsta/GoogleAuthenticator updated and reworked to php8.2 because of inactivity of the original creator.

1418.7k](/packages/sebastiandevs-simplethenticator)[jiripudil/otp

Library that generates and verifies one-time passwords.

2828.3k1](/packages/jiripudil-otp)

PHPackages © 2026

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