OTPInterface
- Full name:
\OTPHP\OTPInterface
Constants
Constant | Visibility | Type | Value |
---|---|---|---|
DEFAULT_DIGITS |
public | 6 | |
DEFAULT_DIGEST |
public | 'sha1' |
Methods
createFromSecret
Create a OTP object from an existing secret.
- This method is static.
Parameters:
Parameter | Type | Description |
---|---|---|
$secret |
non-empty-string |
generate
Create a new OTP object. A random 64 bytes secret will be generated.
- This method is static.
setSecret
Parameters:
Parameter | Type | Description |
---|---|---|
$secret |
non-empty-string |
setDigits
Parameters:
Parameter | Type | Description |
---|---|---|
$digits |
positive-int |
setDigest
Parameters:
Parameter | Type | Description |
---|---|---|
$digest |
non-empty-string |
at
Parameters:
Parameter | Type | Description |
---|---|---|
$input |
0|positive-int |
Return Value:
Return the OTP at the specified timestamp
verify
Verify that the OTP is valid with the specified input. If no input is provided, the input is set to a default value or false is returned.
public verify(non-empty-string $otp, null|0|positive-int $input = null, null|0|positive-int $window = null): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$otp |
non-empty-string | |
$input |
null|0|positive-int | |
$window |
null|0|positive-int |
getSecret
Return Value:
The secret of the OTP
setLabel
Parameters:
Parameter | Type | Description |
---|---|---|
$label |
non-empty-string | The label of the OTP |
getLabel
Return Value:
The label of the OTP
getIssuer
Return Value:
The issuer
setIssuer
Parameters:
Parameter | Type | Description |
---|---|---|
$issuer |
non-empty-string |
isIssuerIncludedAsParameter
Return Value:
If true, the issuer will be added as a parameter in the provisioning URI
setIssuerIncludedAsParameter
Parameters:
Parameter | Type | Description |
---|---|---|
$issuer_included_as_parameter |
bool |
getDigits
Return Value:
Number of digits in the OTP
getDigest
Return Value:
Digest algorithm used to calculate the OTP. Possible values are 'md5', 'sha1', 'sha256' and 'sha512'
getParameter
Parameters:
Parameter | Type | Description |
---|---|---|
$parameter |
non-empty-string |
hasParameter
Parameters:
Parameter | Type | Description |
---|---|---|
$parameter |
non-empty-string |
getParameters
setParameter
Parameters:
Parameter | Type | Description |
---|---|---|
$parameter |
non-empty-string | |
$value |
mixed |
getProvisioningUri
Get the provisioning URI.
getQrCodeUri
Get the provisioning URI.
Parameters:
Parameter | Type | Description |
---|---|---|
$uri |
non-empty-string | The Uri of the QRCode generator with all parameters. This Uri MUST contain a placeholder that will be replaced by the method. |
$placeholder |
non-empty-string | the placeholder to be replaced in the QR Code generator URI |
Automatically generated on 2025-03-18