Skip to content

CodeIgniter library to create and verify Google Authenticator web service's secret codes.

Notifications You must be signed in to change notification settings

alemohamad/ci-google-authenticator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

CodeIgniter Library: Google Authenticator

ci-google-authenticator

About this library

This CodeIgniter's library creates and verifies Google Authenticator web service's secret codes (2-Step Verification).

It can generate secrets, generate codes, validate codes and present a QR-Code for scanning the secret.

This library is a modified version of the PHPGangsta's class.

Its usage is recommended for CodeIgniter 2 or greater.

Google 2-Step Verification

Usage

Load the library

$this->load->library('GoogleAuthenticator');

Generate the secret and QR code

// generates the secret code
$secret = $this->googleauthenticator->createSecret();

// generates the QR code for the link the user's phone with the service
$qrCodeUrl = $this->googleauthenticator->getQRCodeGoogleUrl('Service Name', 'user@email.com', $secret);

// also, you can get a code to test the service
$oneCode = $this->googleauthenticator->getCode($secret);

Verify your phone's code

// get the user's phone code and the secret code that was generated, and verify
$checkResult = $this->googleauthenticator->verifyCode($secret, $code, 2); // 2 = 2*30sec clock tolerance

if ($checkResult) {
    echo 'OK';
} else {
    echo 'FAILED';
}

Ale Mohamad

About

CodeIgniter library to create and verify Google Authenticator web service's secret codes.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages