Skip to content
This repository has been archived by the owner on Apr 28, 2023. It is now read-only.

iamirnet/google-authenticator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Latest Version GitHub last commit Packagist Downloads

Google Authenticator with PHP

Google Authenticator generates 2-Step Verification codes on your phone.

2-Step Verification provides stronger security for your Google Account by requiring a second step of verification when you sign in. In addition to your password, you’ll also need a code generated by the Google Authenticator app on your phone.

Learn more about 2-Step Verification: https://g.co/2step

Installation

composer require iamirnet/google-authenticator
Click for help with installation

Install Composer

If the above step didn't work, install composer and try again.

Debian / Ubuntu

sudo apt-get install curl php-curl
curl -s http://getcomposer.org/installer | php
php composer.phar install

Composer not found? Use this command instead:

php composer.phar require "iamirnet/google-authenticator"

Installing on Windows

Download and install composer:

  1. https://getcomposer.org/download/
  2. Create a folder on your drive like C:\iAmirNet\GoogleAuthenticator
  3. Run command prompt and type cd C:\iAmirNet\GoogleAuthenticator
  4. composer require iamirnet/google-authenticator
  5. Once complete copy the vendor folder into your project.

Getting started

composer require iamirnet/google-authenticator

require 'vendor/autoload.php';
// config by specifying api key and secret
$ga = new \iAmirNet\GoogleAuthenticator\Authenticator("<issuer>","<label>");

=======

Create Secret Key

/**
* Create a new random secret for the Google Authenticator app.
* 16 characters, randomly chosen from the allowed Base32 characters
* equals 10 bytes = 80 bits, as 256^10 = 32^16 = 2^80
*/
print_r($ga->create($issuer = null, $label = null, $width = 200, $height = 200));
View Response
Array
(
    'secret' => 'ILY3AYQEAPUZBUQM',
    'qr' => 'https://chart.googleapis.com/chart?chs=200x200&chld=M|0&cht=qr&chl=otpauth://totp/iAmirNet?secret=ILY3AYQEAPUZBUQM&issuer=iAmirNet'
)

Verify Code

//Check the verification code entered by the user.
print_r($ga->verify($secret, $pin, $relaxed = 'enabled', $last = '')); // return false or time correct

Contribution

  • Give us a star ⭐
  • Fork and Clone! Awesome
  • Select existing issues or create a new issue and give us a PR with your bugfix or improvement after. We love it ❤️

Donate

  • USDT Or TRX: TUE8GiY4vmz831N65McwzZVbA9XEDaLinn 😘❤

About

PHP SDK for Google Authenticator

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages