Download the PHP package nishadil/mfa without Composer
On this page you can find all versions of the php package nishadil/mfa. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package mfa
Short Description A php library for Multi-factor authentication (MFA).
License MIT
Informations about the package mfa
nishadil\mfa
A php library for Multi-factor authentication (MFA). MFA also known as 2FA or two factor authentication.
What is TOTP
The TOTP algorithm follows an open standard documented in RFC 6238. The inputs include a shared secret key and the system time.
What is HOTP
HOTP stands for HMAC-based One-Time Password and is the original standard that TOTP was based on. Both methods use a secret key as one of the inputs, but while TOTP uses the system time for the other input, HOTP uses a counter, which increments with each new validation. With HOTP, both parties increment the counter and use that to compute the one-time password. The HOTP standard is documented in RFC 4226.
Installation
This library can be installed using Composer. To install, please use following command
How to use
Generate Secret Code
To create new secret code for user, call public static mathod Mfa::createSecretCode();
output:
Generate long Secret Code
By default, we defined secret code length to 16 char long. You can change it if you need to generate long code. Accepted values should be in integer and within range of 16 to 128.
eg: now we want to generate a 32 char long secret code. Mfa::setSecretCodeLength(32)->createSecretCode();
output:
Get TOTP from secret code
TOTP stands for Time-based One-Time Passwords and is a common form of Multi-factor authentication (MFA). To generate your TOTP based on your secret key and time you can call public static mathod Mfa::getTOTP( string $secretCode );
output:
Validate TOTP
To validate your TOTP based on your secret key and time you can call public static mathod Mfa::validateTOTP(string $secretCode, string $userProvided_otp);
output:
Get HOTP from secret code
HOTP stands for HMAC-based One-Time Password and is the original standard that TOTP was based on. To generate your HOTP based on your secret key and counter value to call public static mathod Mfa::getHOTP( string $secretCode, int $counter );
output:
Validate HOTP
To validate your HOTP based on your secret key and counter value call public static mathod Mfa::validateHOTP(string $secretCode, string $userProvided_otp, int $counter);
output:
License
This library is licensed for use under the MIT License (MIT)