1. Go to this page and download the library: Download abmmhasan/otp 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/ */
abmmhasan / otp example snippets
use Infocyph\OTP\TOTP;
$secret = TOTP::generateSecret();
$totp = (new TOTP($secret))
->setAlgorithm('sha256');
$otp = $totp->getOTP();
$isValid = $totp->verify($otp);
use Infocyph\OTP\Stores\InMemoryReplayStore;
use Infocyph\OTP\ValueObjects\VerificationWindow;
$store = new InMemoryReplayStore();
$result = $totp->verifyWithWindow(
$otp,
timestamp: time(),
window: new VerificationWindow(past: 1, future: 1),
replayStore: $store,
binding: 'user-42',
);
$result->matched;
$result->matchedTimestep;
$result->driftOffset;
$result->isExact();
$result->isDrifted();
$result->replayDetected;
use Infocyph\OTP\Support\SecretUtility;
$secret = SecretUtility::generate(64);
$normalized = SecretUtility::normalizeBase32('ab cd ef 234===');
$isValid = SecretUtility::isValidBase32($normalized);
use Infocyph\OTP\Support\StepUp;
$
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.