Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Google Authenticator for PHP

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 GAuth.php
Octocat-spinner-32 README.md
README.md

Google Authenticator for PHP

This is a Google Authenticator class for PHP.
It requires a base32 implementation, you can use mine: https://github.com/NTICompass/PHP-Base32

Usage:

Generate QR Code for user to scan:

<?php
  require_once('GAuth.php');
  $auth = new GAuth;
  $key = $auth->getKey();
  echo '<img src="'.$auth->QRCode('YourDomain.com').'" />';
?>

Verifying code:

<?php
  require_once('GAuth.php');
  $auth = new GAuth;
  // otp is the code from the authenticator
  // key is the $key from the above example
  $valid = $auth->verify($_GET['otp'], $_GET['key']);             
?>
Something went wrong with that request. Please try again.