PHP code example of nishadil / mfa

1. Go to this page and download the library: Download nishadil/mfa 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/ */

    

nishadil / mfa example snippets




use Nishadil\Mfa\Mfa;

echo Mfa::createSecretCode();




use Nishadil\Mfa\Mfa;

echo Mfa::setSecretCodeLength(32)->createSecretCode();




use Nishadil\Mfa\Mfa;

$secretCode = "3TYBUTVEXBOBXYTJ6L7NZ4HC7QJWAKMY";
echo Mfa::getTOTP($secretCode);




use Nishadil\Mfa\Mfa;

$secretCode = "3TYBUTVEXBOBXYTJ6L7NZ4HC7QJWAKMY";
$userProvided_otp = "440791";

echo Mfa::validateTOTP($secretCode, $userProvided_otp);




use Nishadil\Mfa\Mfa;

$secretCode = "3TYBUTVEXBOBXYTJ6L7NZ4HC7QJWAKMY";
$counter = 100;
echo Mfa::getHOTP($secretCode,$counter);




use Nishadil\Mfa\Mfa;

$secretCode = "3TYBUTVEXBOBXYTJ6L7NZ4HC7QJWAKMY";
$counter = 100;
$userProvided_otp = "440791";

echo Mfa::validateHOTP($secretCode, $userProvided_otp, $counter);