TotpAlgorithm extends OtpAlgorithm
Table of Contents
Constants
- SYNC_WINDOW = 180
Methods
- __construct() : mixed
- generateOTP() : string
- Main method, generate OTP value for provided counter
- generateUri() : string
- Generate provision URI according to KeyUriFormat
- getAppScheme() : string
- Return algorithm scheme Mostly used for generate provision URI
- getDigest() : string
- Returns digest algorithm used to calculate the OTP.
- getDigits() : int
- Return digits (password length)
- getSecret() : string
- Return used secret (binary)
- getSyncParameters() : string
- Return synchronized user params for provided inputs
- getType() : string
- Return OtpAlgorithm type
- isTwoCodeRequired() : bool
- Require or not _two_ code for synchronize parameters
- setInterval() : $this
- setSecret() : $this
- Set new secret
- setWindow() : $this
- timecode() : int
- Make OTP counter from provided timestamp
- verify() : array<string|int, mixed>
- Verify provided input
Constants
SYNC_WINDOW
public
mixed
SYNC_WINDOW
= 180
Methods
__construct()
public
__construct([array<string|int, mixed> $initParams = [] ]) : mixed
Parameters
- $initParams : array<string|int, mixed> = []
generateOTP()
Main method, generate OTP value for provided counter
public
generateOTP(string|int $counter) : string
Parameters
- $counter : string|int
-
Counter.
Return values
stringgenerateUri()
Generate provision URI according to KeyUriFormat
public
generateUri(mixed $label[, array<string|int, mixed> $opts = [] ]) : string
Parameters
- $label : mixed
-
User label.
- $opts : array<string|int, mixed> = []
-
Additional URI parameters, e.g. ['image' => 'http://example.com/my_logo.png'] .
Tags
Return values
stringgetAppScheme()
Return algorithm scheme Mostly used for generate provision URI
public
getAppScheme() : string
Return values
stringgetDigest()
Returns digest algorithm used to calculate the OTP.
public
getDigest() : string
Mostly used for generate provision URI
Return values
stringgetDigits()
Return digits (password length)
public
getDigits() : int
Return values
intgetSecret()
Return used secret (binary)
public
getSecret() : string
Return values
stringgetSyncParameters()
Return synchronized user params for provided inputs
public
getSyncParameters(mixed $inputA, mixed $inputB) : string
Parameters
- $inputA : mixed
-
First code.
- $inputB : mixed
-
Second code. Must be provided if current OtpAlgorithm required it (see isTwoCodeRequired).
Tags
Return values
stringgetType()
Return OtpAlgorithm type
public
getType() : string
Return values
stringisTwoCodeRequired()
Require or not _two_ code for synchronize parameters
public
isTwoCodeRequired() : bool
Return values
boolsetInterval()
public
setInterval(int $interval) : $this
Parameters
- $interval : int
Return values
$thissetSecret()
Set new secret
public
setSecret(string $secret) : $this
Parameters
- $secret : string
-
Secret (binary).
Return values
$thissetWindow()
public
setWindow(int $window) : $this
Parameters
- $window : int
Return values
$thistimecode()
Make OTP counter from provided timestamp
public
timecode(int $timestamp) : int
Parameters
- $timestamp : int
-
Timestamp.
Return values
intverify()
Verify provided input
public
verify(mixed $input[, mixed $params = null ][, mixed $time = null ]) : array<string|int, mixed>
Parameters
- $input : mixed
-
Input received from user.
- $params : mixed = null
-
Synchronized user params, saved for this algorithm (see getSyncParameters).
- $time : mixed = null
Tags
Return values
array<string|int, mixed> —[ bool isSuccess (Valid input or not), string newParams (Updated user params for this OtpAlgorithm) ]