OtpAlgorithm
Table of Contents
Methods
- 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
- setSecret() : $this
- Set new secret
- verify() : array<string|int, mixed>
- Verify provided input
Methods
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(string $label[, array<string|int, mixed> $opts = [] ]) : string
Parameters
- $label : string
-
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
abstract getSyncParameters(string $inputA, string|null $inputB) : string
Parameters
- $inputA : string
-
First code.
- $inputB : string|null
-
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
boolsetSecret()
Set new secret
public
setSecret(string $secret) : $this
Parameters
- $secret : string
-
Secret (binary).
Return values
$thisverify()
Verify provided input
public
abstract verify(string $input[, string $params = null ]) : array<string|int, mixed>
Parameters
- $input : string
-
Input received from user.
- $params : string = null
-
Synchronized user params, saved for this algorithm (see getSyncParameters).
Return values
array<string|int, mixed> —[ bool isSuccess (Valid input or not), string newParams (Updated user params for this OtpAlgorithm) ]