PHP code example of wolfcode / authenticator
1. Go to this page and download the library: Download wolfcode/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/ */
wolfcode / authenticator example snippets
// base on https://github.com/PHPGangsta/GoogleAuthenticator
public function test()
{
$ga = new \Wolfcode\Authenticator\google\PHPGangstaGoogleAuthenticator();
$secret = $ga->createSecret(32);
// xxx You can customize the name displayed in the APP
// xxx 可以自定义在APP中显示的名称
$dataUri = $ga->getQRCode('xxx',$secret);
return $dataUri;
// "<img src='{$dataUri}' alt=''>";
}
// $code: Random code on the app
public function checkCode($secret,$code)
{
$ga = new \Wolfcode\Authenticator\google\PHPGangstaGoogleAuthenticator();
$check = $ga->verifyCode($secret,$code);
var_dump($check);
}
public function test()
{
// Not yet supported
}