rytescube / otpkit
Laravel package to generate otp or one time password
v1.0.0
2020-05-12 15:18 UTC
This package is auto-updated.
Last update: 2025-04-13 03:51:23 UTC
README
Laravel package to generate otp or one time password.
Installation
In Laravel 5.5+ otpkit will install via the new package discovery feature so you only need to add the package to your composer.json file
composer require rytescube/otpkit
after installation you should see
Discovered Package: rytescube/otpkit
and you are ready to go
Basic Usage
For quick generation of an OTP just do
Otp::generate();
This will generate a numeric OTP having length 4.
Advanced Usage
OTP generation
Generate an OTP using three variant. You can set the length of the OTP. If not supplied it will generate an OTP having default length 4.
Otp::generate($type,$length);
Params | Value | Description | Example |
---|---|---|---|
$type | Otp::ALPHA |
Generates only alphabetic characters type OTP | Otp::generate(Otp::ALPHA); //AXBZ |
Otp::NUM (Default) |
Generates only numeric type OTP | Otp::generate(Otp::NUM); //1234 |
|
Otp::ALPHA_NUM |
Generates mix of alphabetic characters & numeric type OTP | Otp::generate(Otp::ALPHA_NUM); //1A3D |
|
$length | 4 (Default) | 5 | 6 | Decides the length of the OTP. | Otp::generate(Otp::ALPHA_NUM,5); //2X8DT |