PHP code example of iamirnet / google-authenticator
1. Go to this page and download the library: Download iamirnet/google-authenticator library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
iamirnet / google-authenticator example snippets
// config by specifying api key and secret
$ga = new \iAmirNet\GoogleAuthenticator\Authenticator("<issuer>","<label>");
/**
* 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));
//Check the verification code entered by the user.
print_r($ga->verify($secret, $pin, $relaxed = 'enabled', $last = '')); // return false or time correct