PHPackages                             jocic/google-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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. jocic/google-authenticator

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

jocic/google-authenticator
==========================

Complete &amp; easy-to-implement MFA solution for use with Google Authenticator App.

1.0.0(7y ago)251.2k3[2 PRs](https://github.com/jocic/PHP.GoogleAuthenticator/pulls)MITPHPPHP &gt;=7.0

Since Jan 7Pushed 1y ago3 watchersCompare

[ Source](https://github.com/jocic/PHP.GoogleAuthenticator)[ Packagist](https://packagist.org/packages/jocic/google-authenticator)[ RSS](/packages/jocic-google-authenticator/feed)WikiDiscussions master Synced 1mo ago

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

Google Authenticator
====================

[](#google-authenticator)

[![Build Status](https://camo.githubusercontent.com/8e35321a03c00e814199fda18d3b712bef48dc9b1223c1442580bbd6514f8b99/68747470733a2f2f7472617669732d63692e6f72672f6a6f6369632f5048502e476f6f676c6541757468656e74696361746f722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/jocic/PHP.GoogleAuthenticator) [![Coverage Status](https://camo.githubusercontent.com/1097d073874116005118b62aba248e68e01b0ecf6b9699d154b783b97538ac04/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6a6f6369632f5048502e476f6f676c6541757468656e74696361746f722f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/jocic/PHP.GoogleAuthenticator?branch=master) [![Codacy Badge](https://camo.githubusercontent.com/40c465f20b353f61b65042022b84a15f01e864f3a1b67f3b6b672d12925f44f1/68747470733a2f2f6170692e636f646163792e636f6d2f70726f6a6563742f62616467652f47726164652f6337633138623438363661353465373962313835393738653561313830663036)](https://www.codacy.com/app/jocic/PHP.GoogleAuthenticator?utm_source=github.com&utm_medium=referral&utm_content=jocic/PHP.GoogleAuthenticator&utm_campaign=Badge_Grade) [![Latest Stable Version](https://camo.githubusercontent.com/6e0f44dd4b44a79b9d021653004f1ad724c74d3d387f927e4dd68012173a79f3/68747470733a2f2f706f7365722e707567782e6f72672f6a6f6369632f676f6f676c652d61757468656e74696361746f722f762f737461626c65)](https://packagist.org/packages/jocic/google-authenticator) [![License](https://camo.githubusercontent.com/d2a1ef213f29ecc15dac95e68e1aef74538fe758ebd0ee90369c7841f28d8d3f/68747470733a2f2f706f7365722e707567782e6f72672f6a6f6369632f676f6f676c652d61757468656e74696361746f722f6c6963656e7365)](https://packagist.org/packages/jocic/google-authenticator)

Google Authenticator is a mini PHP library for implementing Multi-Factor Authentication by utilizing Google's Authenticator App. It was written to simplify the usually complicated implementation process.

[![Project Image](images/project-image-small.png)](images/project-image-small.png)

Following specifications were referenced:

- [RFC 4226](other/specifications/rfc4226.txt) - HMAC-Based One-Time Password Algorithm
- [RFC 6238](other/specifications/rfc6238.txt) - TOTP: Time-Based One-Time Password Algorithm
- [RFC 6287](other/specifications/rfc6287.txt) - OCRA: OATH Challenge-Response Algorithm

[![Buy Me Coffee](images/buy-me-coffee.png)](https://www.paypal.me/DjordjeJocic)

**Song of the project:** [Iron Maiden - The Trooper](https://www.youtube.com/watch?v=X4bgXH3sJ2Q)

Versioning Scheme
-----------------

[](#versioning-scheme)

I use a 3-digit [Semantic Versioning](https://semver.org/spec/v2.0.0.html) identifier, for example 1.0.2. These digits have the following meaning:

- The first digit (1) specifies the MAJOR version number.
- The second digit (0) specifies the MINOR version number.
- The third digit (2) specifies the PATCH version number.

Complete documentation can be found by following the link above.

Examples
--------

[](#examples)

Following examples should be more then enough to get you started. I tried my best to make them as simple as possible so that everyone, even junior developers, can successfully use them for implementing two-factor authentication.

1. [Creating a Secret](https://github.com/jocic/PHP.GoogleAuthenticator/wiki/Creating-a-Secret)
2. [Secret Creation Methods](https://github.com/jocic/PHP.GoogleAuthenticator/wiki/Secret-Creation-Methods)
3. [Setting Existing Secrets](https://github.com/jocic/PHP.GoogleAuthenticator/wiki/Setting-Existing-Secrets)
4. [Creating an Account](https://github.com/jocic/PHP.GoogleAuthenticator/wiki/Creating-an-Account)
5. [Account Management](https://github.com/jocic/PHP.GoogleAuthenticator/wiki/Account-Management)
6. [QR Codes](https://github.com/jocic/PHP.GoogleAuthenticator/wiki/QR-Codes)
7. [Code Validation](https://github.com/jocic/PHP.GoogleAuthenticator/wiki/Code-Validation)

For additional examples please review the official project's [wiki](https://github.com/jocic/PHP.GoogleAuthenticator/wiki).

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

[](#requirements)

You only need to have PHP &gt;=7.0 available on your system to use **Google Authenticator** in your application. However, for running unit tests, you need to have the following extensions installed:

- [Multibyte String](https://secure.php.net/manual/en/book.mbstring.php)
- [DOM](https://secure.php.net/manual/en/dom.setup.php)

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

[](#installation)

There's two ways you can add **Google Authenticator** library to your project:

- Copying files from the "source" directory to your project and requiring the "Autoload.php" script (this includes doing the same for project's dependencies ex. Encoders)
- Via Composer, by executing the command below

```
composer require jocic/google-authenticator 1.0.0
```

Tests
-----

[](#tests)

Following unit tests are available:

- **Essentials** - Tests for library's essentials ex. Autoloader, Base 32 encoder, etc.
- **QR Generators** - Tests for available QR code generators in the library.
- **Elements** - Tests for library's core elements ex. Secret, Account, etc.

You can execute them easily from the terminal like in the example below.

```
bash ./scripts/phpunit.sh --testsuite essentials
bash ./scripts/phpunit.sh --testsuite qr-generators
bash ./scripts/phpunit.sh --testsuite elements
```

Please don’t forget to install necessary dependencies before attempting to do the God's work above. They may be important.

```
bash ./scripts/composer.sh install
```

Contribution
------------

[](#contribution)

Please review the following documents if you are planning to contribute to the project:

- [Contributor Covenant Code of Conduct](code-of-conduct.md)
- [Contribution Guidelines](contributing.md)
- [Pull Request Template](pull-request-template.md)
- [MIT License](license.md)

Integration
-----------

[](#integration)

My hourly rate is fairly reasonable so, if you need help with integrating **Google Authenticator** to your existing project, feel free to contact me via the email below.

Integration inquiries:

Support
-------

[](#support)

Please don't hesitate to contact me if you have any questions, ideas, or concerns.

My Twitter account is: [@jocic\_91](https://www.twitter.com/jocic_91)

My support E-Mail address is:

Copyright &amp; License
-----------------------

[](#copyright--license)

Copyright (C) 2018 Đorđe Jocić

Licensed under the MIT license.

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance27

Infrequent updates — may be unmaintained

Popularity28

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 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 ~2001 days

Total

2

Last Release

687d ago

PHP version history (2 changes)1.0.0PHP &gt;=7.0

1.1.0.x-devPHP &gt;=8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/4b022fe84b009f3dcc944f03764d393cbda99123867e1bc7fefa6b1d93919b1d?d=identicon)[jocic](/maintainers/jocic)

---

Top Contributors

[![jocic](https://avatars.githubusercontent.com/u/10118993?v=4)](https://github.com/jocic "jocic (159 commits)")

---

Tags

authenticationgoogle-authenticatorlibrarymulti-factor-authenticationphpsecuritytwo-factor-authenticationMFA

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/jocic-google-authenticator/health.svg)

```
[![Health](https://phpackages.com/badges/jocic-google-authenticator/health.svg)](https://phpackages.com/packages/jocic-google-authenticator)
```

###  Alternatives

[robthree/twofactorauth

Two Factor Authentication

1.2k10.5M66](/packages/robthree-twofactorauth)[paragonie/multi-factor

Vendor-agnostic two-factor authentication library

142195.5k2](/packages/paragonie-multi-factor)[ellaisys/aws-cognito

AWS Cognito package that allows Auth and other related features using the AWS SDK for PHP

120220.7k1](/packages/ellaisys-aws-cognito)[chillerlan/php-authenticator

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

58119.1k2](/packages/chillerlan-php-authenticator)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3911.9k](/packages/rawilk-profile-filament-plugin)[vxm/yii2-mfa

Multi-factor authentication for yii2

1440.5k](/packages/vxm-yii2-mfa)

PHPackages © 2026

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