Skip to content

mahdimsr/Laravel-OTP

Repository files navigation

laravel OTP options

Latest Version on Packagist run-tests Fix PHP code style issues

generate OTP and validate it

Installation

You can install the package via composer:

composer require msr/laravel-otp

Usage

to generate one time password you should pass a BaseOTPGenerator inheritance class:

$otp = new Msr\OTP\OTP();


$otp->generate(Msr\OTP\Generator\NumericGenerator::class);
$otp->save('sth-like-cache-name')

// to get generate password
$otp->generatedPassword();
// to get name that you set for otp
$otp->passwordName();

// to get password with its name
\Msr\OTP\OTP::password('the-name-you-passed-to-save-function-before')

Validation

to validate generated password:

\Msr\OTP\OTP::validate($passwordValue, 'password-name')

// or for validation rule
$request->validate([
    'otp-input-name' => [new \Msr\OTP\OTPValidationRule('password-name')]
])

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Credits

License

The MIT License (MIT). Please see License File for more information.

About

laravel OTP options

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages