PHPackages                             mindgruve/two-factor-auth - 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. mindgruve/two-factor-auth

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

mindgruve/two-factor-auth
=========================

PHP Implementation of RFC 6238 used by the Google Authenticator Token Generator

1.0.0(9y ago)182MITPHP

Since Mar 9Pushed 9y ago4 watchersCompare

[ Source](https://github.com/mindgruve/two-factor-authentication)[ Packagist](https://packagist.org/packages/mindgruve/two-factor-auth)[ RSS](/packages/mindgruve-two-factor-auth/feed)WikiDiscussions master Synced 2mo ago

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

Two-Factor-Authentication
=========================

[](#two-factor-authentication)

This PHP Library implements TOTP algorithm popularized by GoogleAuthenticator. It provides a simple, secure, and user-friendly 2-Factor-Authentication scheme.

### Algorithm

[](#algorithm)

The Time-Based One-Time Password Algorithm is described in RFC 26238 is located at

### Generating Secrets

[](#generating-secrets)

1. Have your users download the GoogleAuthenticator app to their smart phone. Links to [Android Play Store](https://play.google.com/store/apps/details?id=com.google.android.apps.authenticator2&hl=en) and [Apple App Store](https://itunes.apple.com/us/app/google-authenticator/id388497605?mt=8)
2. Generate a Secret for each user and store it in your application

    ```
     use Mindgruve\TwoFactorAuth\Secret;
     $secret = new Secret();
     // Secrets can be Serialized to a Base32 String
     $serializedSecret = $secret->asBase32();
     // Save this $serializedSecret in your application for this user

    ```
3. Have your user load the secret into GoogleAuthenticator.

    ```
     use Mindgruve\TwoFactorAuth\Secret;
     $secret = new Secret();
     /**
      * Display a QR code for users to scan
      */
