PHP code example of theodorejb / multi-factor

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

    

theodorejb / multi-factor example snippets



use ParagonIE\MultiFactor\Vendor\GoogleAuth;

$seed = random_bytes(20);
$auth = new GoogleAuth($seed);
$auth->makeQRCode(null, 'php://output', '[email protected]', 'Issuer', 'Label');


use ParagonIE\MultiFactor\OneTime;
use ParagonIE\MultiFactor\OTP\TOTP;

// You can use TOTP or HOTP
$otp = new OneTime($seed, new TOTP());

if (\password_verify($_POST['password'], $storedHash)) {
    if ($otp->validateCode($_POST['2facode'], time())) {
        // Login successful    
    }
}