1. Go to this page and download the library: Download equit/totp 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/ */
$isVerified = (new Totp(decrypt($user->totpSecret))->verify($inputOtp);
$isVerified = (new Totp(decrypt($user->totpSecret))->verify(password: $inputOtp, window: 1);
$generator = UrlGenerator::from("Equit");
foreach ($users as $user) {
$totp = new Totp(algorithm: Totp::Sha512Algorithm);
$user->totpSecret = $totp->secret();
$user->save();
$user->notify($generator->for($user->username)->urlFor($totp));
}
unset($totp);
$isVerified = (new Totp(decrypt($user->totpSecret))->verify($userInput);
$isVerified = (new Totp(decrypt($user->totpSecret))->verify(password: $inputOtp, window: 1);
$totp = new Totp(decrypt($user->totpSecret));
if ($user->highestUsedTotpCounter < $totp->counter()) {
if ($totp->verify($inputOtp)) {
$user->highestUsedTotpCounter = $totp->counter();
$user->save();
// user is authenticated
} else {
// incorrect OTP
}
} else {
// OTP has already been used
}
// ensure the secret is shredded
scrubString($inputOtp);
unset($totp);
$totp = new Totp(decrypt($user->totpSecret));
$window = min(1, $totp->counter() - $user->highestUsedTotpCounter - 1);
if (0 <= $window) {
if ($totp->verify(password: $inputOtp, window: $window)) {
...
}
}
// ensure the secret is shredded
scrubString($inputOtp);
unset($totp);
// when provisioning
$totp = new Totp(hashAlgorithm: Totp::Sha256Algorithm);
// when verifying
$totp = new Totp(secret: decrypt($user->totpSecret), hashAlgorithm: Totp::Sha256Algorithm);
// when provisioning
$totp = new Totp(hashAlgorithm: Totp::Sha512Algorithm);
// when verifying
$totp = new Totp(secret: decrypt($user->totpSecret), hashAlgorithm: Totp::Sha512Algorithm);
// when provisioning
$totp = new Totp(timeStep: 60);
// when verifying
$totp = new Totp(secret: decrypt($user->totpSecret), timeStep: 60);
// when provisioning
$totp = new Totp(referenceTime: 86400);
// when verifying
$totp = new Totp(secret: decrypt($user->totpSecret), referenceTime: 86400);
// when provisioning
$totp = new Totp(referenceTime: new DateTime("1970-01-02 00:00:00", new DateTimeZone("UTC")));
// when verifying
$totp = new Totp(secret: decrypt($user->totpSecret), referenceTime: new DateTime("1970-01-02 00:00:00", new DateTimeZone("UTC")));
// when provisioning
$totp = new Totp(timeStep: 60, referenceTime: new DateTime("1970-01-02 00:00:00", new DateTimeZone("UTC")));
// when verifying
$totp = new Totp(secret: decrypt($user->totpSecret), timeStep: 60, referenceTime: new DateTime("1970-01-02 00:00:00", new DateTimeZone("UTC")));
// when provisioning
$totp = new Totp(
timeStep: 60,
referenceTime: new DateTime("1970-01-02 00:00:00", new DateTimeZone("UTC")),
hashAlgorithm: Totp::Sha512Algorithm
);
// when verifying
$totp = new Totp(
secret: decrypt($user->totpSecret),
timeStep: 60,
referenceTime: new DateTime("1970-01-02 00:00:00", new DateTimeZone("UTC")),
hashAlgorithm: Totp::Sha512Algorithm
);
// when provisioning
$totp = Totp::eightDigits();
// when verifying
$totp = Totp::eightDigits(decrypt($user->totpSecret));
// when provisioning
$totp = Totp::eightDigits(
timeStep: 60,
referenceTime: new DateTime("1970-01-02 00:00:00", new DateTimeZone("UTC")),
hashAlgorithm: Totp::Sha512Algorithm
);
// when verifying
$totp = Totp::eightDigits(
secret: decrypt($user->totpSecret),
timeStep: 60,
referenceTime: new DateTime("1970-01-02 00:00:00", new DateTimeZone("UTC")),
hashAlgorithm: Totp::Sha512Algorithm
);
// when provisioning
$totp = Totp::integer(9);
// when verifying
$totp = Totp::integer(digits: 9, secret: decrypt($user->totpSecret));
// when provisioning
$totp = Totp::integer(
digits: 9,
timeStep: 60,
referenceTime: new DateTime("1970-01-02 00:00:00", new DateTimeZone("UTC")),
hashAlgorithm: Totp::Sha512Algorithm
);
// when verifying
$totp = Totp::integer(
digits: 9,
secret: decrypt($user->totpSecret),
timeStep: 60,
referenceTime: new DateTime("1970-01-02 00:00:00", new DateTimeZone("UTC")),
hashAlgorithm: Totp::Sha512Algorithm
);
// when provisioning
$totp = new Totp(renderer: new Steam());
// when verifying
$totp = new Totp(secret: decrypt($user->totpSecret), renderer: new Steam());
// when provisioning
$totp = new Totp(
renderer: new Steam(),
timeStep: 60,
referenceTime: new DateTime("1970-01-02 00:00:00", new DateTimeZone("UTC")),
hashAlgorithm: Totp::Sha512Algorithm
);
// when verifying
$totp = new Totp(
renderer: new Steam(),
secret: decrypt($user->totpSecret),
timeStep: 60,
referenceTime: new DateTime("1970-01-02 00:00:00", new DateTimeZone("UTC")),
hashAlgorithm: Totp::Sha512Algorithm
);
$totp = new Totp(Base32::decode(decrypt($user->totpSecret)));
$totp = new Totp(Base64::decode(decrypt($user->totpSecret)));
$totp = new Totp(TotpSecret::fromBase32(decrypt($user->totpSecret)));
$totp = new Totp(TotpSecret::fromBase64(decrypt($user->totpSecret)));
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.