PHP code example of stealthfirems / laravel-otp-module
1. Go to this page and download the library: Download stealthfirems/laravel-otp-module 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/ */
stealthfirems / laravel-otp-module example snippets
use StealthFireMS\LaravelOTPModule\Totp;
// Generate and persist a TOTP secret for a user
$totp = new Totp();
$response = $totp->generate_totp($user_id, $totp_name); // $totp_name is optional
// Validate a TOTP code for a user
$response = $totp->validate_totp($user_id, $totp_code);
// Generate and store a TOTP secret for user ID 89, named "Bitwarden"
$response = $totp->generate_totp(89, 'Bitwarden');
/*
$response = (object)[
'status' => true,
'secret' => 'BASE32SECRET...',
'uri' => 'otpauth://totp/...',
'message' => 'TOTP secret generated and saved'
];
*/
// Validate a TOTP code for user
$response = $totp->validate_totp(89, '123456');
/*
$response = (object)[
'status' => true,
'message' => 'TOTP is valid'
];
*/
bash
php artisan migrate
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.