HOTP
- Full name:
\OTPHP\HOTP
- Parent class:
\OTPHP\OTP
- This class is marked as final and can't be subclassed
- This class implements:
\OTPHP\HOTPInterface
- This class is a Final class
See Also:
- \OTPHP\Test\HOTPTest -
Constants
Constant | Visibility | Type | Value |
---|---|---|---|
DEFAULT_WINDOW |
private | 0 |
Methods
create
Create a new HOTP object.
public static create(null|string $secret = null, int $counter = self::DEFAULT_COUNTER, string $digest = self::DEFAULT_DIGEST, int $digits = self::DEFAULT_DIGITS): self
If the secret is null, a random 64 bytes secret will be generated.
- This method is static.
Parameters:
Parameter | Type | Description |
---|---|---|
$secret |
null|string | |
$counter |
int | |
$digest |
string | |
$digits |
int |
createFromSecret
Create a OTP object from an existing secret.
- This method is static.
Parameters:
Parameter | Type | Description |
---|---|---|
$secret |
string |
generate
Create a new OTP object. A random 64 bytes secret will be generated.
- This method is static.
getCounter
The initial counter (a positive integer).
getProvisioningUri
Get the provisioning URI.
verify
If the counter is not provided, the OTP is verified at the actual counter.
Parameters:
Parameter | Type | Description |
---|---|---|
$otp |
string | |
$counter |
null|int | |
$window |
null|int |
setCounter
Parameters:
Parameter | Type | Description |
---|---|---|
$counter |
int |
getParameterMap
updateCounter
Parameters:
Parameter | Type | Description |
---|---|---|
$counter |
positive-int |
getWindow
Parameters:
Parameter | Type | Description |
---|---|---|
$window |
null|0|positive-int |
verifyOtpWithWindow
private verifyOtpWithWindow(non-empty-string $otp, 0|positive-int $counter, null|0|positive-int $window): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$otp |
non-empty-string | |
$counter |
0|positive-int | |
$window |
null|0|positive-int |
Inherited methods
getParameters
getSecret
getLabel
setLabel
Parameters:
Parameter | Type | Description |
---|---|---|
$label |
string |
getIssuer
setIssuer
Parameters:
Parameter | Type | Description |
---|---|---|
$issuer |
string |
isIssuerIncludedAsParameter
setIssuerIncludedAsParameter
Parameters:
Parameter | Type | Description |
---|---|---|
$issuer_included_as_parameter |
bool |
getDigits
getDigest
hasParameter
Parameters:
Parameter | Type | Description |
---|---|---|
$parameter |
string |
getParameter
Parameters:
Parameter | Type | Description |
---|---|---|
$parameter |
string |
setParameter
Parameters:
Parameter | Type | Description |
---|---|---|
$parameter |
string | |
$value |
mixed |
setSecret
Parameters:
Parameter | Type | Description |
---|---|---|
$secret |
string |
setDigits
Parameters:
Parameter | Type | Description |
---|---|---|
$digits |
int |
setDigest
Parameters:
Parameter | Type | Description |
---|---|---|
$digest |
string |
getParameterMap
hasColon
Parameters:
Parameter | Type | Description |
---|---|---|
$value |
non-empty-string |
__construct
Parameters:
Parameter | Type | Description |
---|---|---|
$secret |
non-empty-string |
getQrCodeUri
Get the provisioning URI.
Parameters:
Parameter | Type | Description |
---|---|---|
$uri |
string | The Uri of the QRCode generator with all parameters. This Uri MUST contain a placeholder that will be replaced by the method. |
$placeholder |
string | the placeholder to be replaced in the QR Code generator URI |
at
Parameters:
Parameter | Type | Description |
---|---|---|
$input |
int |
Return Value:
Return the OTP at the specified timestamp
generateSecret
-
This method is static.
-
This method is final.
generateOTP
The OTP at the specified input.
Parameters:
Parameter | Type | Description |
---|---|---|
$input |
0|positive-int |
filterOptions
Parameters:
Parameter | Type | Description |
---|---|---|
$options |
array |
generateURI
protected generateURI(non-empty-string $type, array<non-empty-string,mixed> $options): non-empty-string
Parameters:
Parameter | Type | Description |
---|---|---|
$type |
non-empty-string | |
$options |
array |
compareOTP
Parameters:
Parameter | Type | Description |
---|---|---|
$safe |
non-empty-string | |
$user |
non-empty-string |
getDecodedSecret
intToByteString
Parameters:
Parameter | Type | Description |
---|---|---|
$int |
0|positive-int |
Automatically generated on 2025-03-18