1. Go to this page and download the library: Download liquid-cats/g2fa 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/ */
liquid-cats / g2fa example snippets
Copy code
use LiquidCats\G2FA\TOTP;
use LiquidCats\G2FA\Enums\Algorithm;
use LiquidCats\G2FA\ValueObjects\SecretKey;
$totp = new TOTP(Algorithm::SHA512, 6, 30, 1);
$secretKey = new SecretKey('YOUR_SECRET_KEY');
$otp = $totp->now($secretKey);
// To verify OTP
$isValid = $totp->verify($secretKey, $otp);
Copy code
use LiquidCats\G2FA\ValueObjects\SecretKey;
// Creating a SecretKey
$secretKey = new SecretKey('YOUR_SECRET_KEY');
// Decoding a SecretKey
$decodedKey = $secretKey->decode();
// Generating a new SecretKey
$newSecretKey = SecretKey::generate();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.