1. Go to this page and download the library: Download mkd/laravel-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/ */
mkd / laravel-otp example snippets
use MKD\LaravelOTP\LaravelOTP;
$secret = 'WSRNGQX4J57FL2POVHDAMBI6ZTK3CYUE'; // Base32 encoded secret
$otpService = LaravelOTP::make($secret);
// Generate current OTP
$currentOTP = $otpService->now();
echo "Current OTP: $currentOTP\n";
// Verify the OTP
$isValid = $otpService->verifyTOTP($currentOTP);
echo $isValid ? "OTP is valid!" : "OTP is invalid!";
use MKD\LaravelOTP\LaravelOTP;
$otpService = LaravelOTP::make('your-secret-key');
$otp = $otpService->now();
$otp = $otpService->last();
$otp = $otpService->next();
$otp = $otpService->at(-1); // Last TOTP
$otp = $otpService->at(1); // Next TOTP
$secretKey = $otpService->generateSecretKey();
$otp = $otpService->atCounter(1); // OTP for counter 1