PHP code example of oops / totp-authenticator
1. Go to this page and download the library: Download oops/totp-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/ */
oops / totp-authenticator example snippets
$totpAuthenticator = (new Oops\TotpAuthenticator\Security\TotpAuthenticator)
->setIssuer('MyApp')
->setTimeWindow(1);
$secret = $totpAuthenticator->getRandomSecret();
$uri = $totpAuthenticator->getTotpUri($secret, $accountName);
if ($totpAuthenticator->verifyCode($code, $secret)) {
// successfully verified
} else {
// incorrect code
}