Motp
Mobile One Time Password generator/validator, based on the http://motp.sourceforge.net specification.
Table of Contents
Properties
| $drift | |
| $length | |
| $moving_factor | |
| $pin | |
| $secret |
Methods
| __construct() | Creates a new Motp object with the given seeded values |
| checkOtp() | Attempts to find a match for the given one time password with the given time value. |
| opt() | Generates a one time password based on the given time and the preset secret and pin. |
| seed() | Seed the Motp object with the given values |
| truncate() | Truncates the given one time password, making it suitable for use. |
Methods
__construct()
Creates a new Motp object with the given seeded values
public
__construct([string $pin = null ][, string $secret = null ][, int $length = 6 ]) : mixed
Parameters
- $pin : string = null
-
The pin to use for this one time password
- $secret : string = null
-
The secret hash to use for this one time password
- $length : int = 6
-
The length of the one time password
checkOtp()
Attempts to find a match for the given one time password with the given time value.
public
checkOtp(string $otp, int $time) : bool
Parameters
- $otp : string
-
A suspected one time password
- $time : int
-
The time around which the given otp should have originated
Return values
bool —True if the one time password is valid, false otherwise
opt()
Generates a one time password based on the given time and the preset secret and pin.
public
opt(int $time) : string
Parameters
- $time : int
-
The time to use as a seed for this one time password
Tags
Return values
string —The one time password generated by the given time
seed()
Seed the Motp object with the given values
public
seed(string $pin, string $secret[, int $length = 6 ]) : mixed
Parameters
- $pin : string
-
The pin to use for this one time password
- $secret : string
-
The secret hash to use for this one time password
- $length : int = 6
-
The length of the one time password
truncate()
Truncates the given one time password, making it suitable for use.
private
truncate(string $otp) : string
Parameters
- $otp : string
-
The one time password to truncate
Return values
string —The truncated one time password