hanhan/google-authenticator

There is no license information available for the latest version (1.0.0) of this package.

Google身份验证器,Google两步验证, Google Authenticator,Google Authenticator 2-factor authentication

1.0.0 2024-10-12 15:30 UTC

This package is auto-updated.

Last update: 2025-06-04 19:08:55 UTC


README

Google身份验证器, Google两步验证,Google Authenticator, 2-factor authentication

<?php
require_once 'Hanhan/GoogleAuthenticator.php';

$google = new GoogleAuthenticator();
$secret = $google->createSecret();
echo "Secret is: ".$secret."\n\n";

$qrCodeUrl = $google->getQRCodeGoogleUrl('Blog', $secret);
echo "Google Charts URL for the QR-Code: ".$qrCodeUrl."\n\n";

$oneCode = $google->getCode($secret);
echo "Checking Code '$oneCode' and Secret '$secret':\n";

$checkResult = $google->verifyCode($secret, $oneCode, 2);    // 2 = 2*30sec clock tolerance
if ($checkResult) {
    echo 'OK';
} else {
    echo 'FAILED';
}