Moodle PHP Documentation 5.1
Moodle 5.1dev (Build: 20250711) (9addea9f0ac)
OTPHP\TOTPInterface Interface Reference
Inheritance diagram for OTPHP\TOTPInterface:
OTPHP\OTPInterface OTPHP\TOTP

Public Member Functions

 at (int $input)
 Generate the OTP at the specified input.
 
 expiresIn ()
 
 getDigest ()
 
 getDigits ()
 
 getEpoch ()
 
 getIssuer ()
 
 getLabel ()
 
 getParameter (string $parameter)
 
 getParameters ()
 
 getPeriod ()
 Get the period of time for OTP generation (a non-null positive integer, in second).
 
 getProvisioningUri ()
 Get the provisioning URI.
 
 getQrCodeUri (string $uri, string $placeholder)
 Get the provisioning URI.
 
 getSecret ()
 
 hasParameter (string $parameter)
 
 isIssuerIncludedAsParameter ()
 
 now ()
 Return the TOTP at the current time.
 
 setDigest (string $digest)
 
 setDigits (int $digits)
 
 setEpoch (int $epoch)
 
 setIssuer (string $issuer)
 
 setIssuerIncludedAsParameter (bool $issuer_included_as_parameter)
 
 setLabel (string $label)
 
 setParameter (string $parameter, mixed $value)
 
 setPeriod (int $period)
 
 setSecret (string $secret)
 
 verify (string $otp, null|int $input=null, null|int $window=null)
 Verify that the OTP is valid with the specified input.
 

Static Public Member Functions

static create (null|string $secret=null, int $period=self::DEFAULT_PERIOD, string $digest=self::DEFAULT_DIGEST, int $digits=self::DEFAULT_DIGITS)
 
static createFromSecret (string $secret)
 
static generate ()
 Create a new OTP object.
 

Public Attributes

const DEFAULT_DIGEST = 'sha1'
 
const DEFAULT_DIGITS = 6
 
const DEFAULT_EPOCH = 0
 
const DEFAULT_PERIOD = 30
 

Member Function Documentation

◆ at()

OTPHP\OTPInterface::at ( int $input)
inherited

Generate the OTP at the specified input.

Parameters
0 | positive-int$input
Return values
non-empty-stringReturn the OTP at the specified timestamp

Implemented in OTPHP\OTP, and OTPHP\TOTP.

◆ generate()

static OTPHP\OTPInterface::generate ( )
staticinherited

Create a new OTP object.

A random 64 bytes secret will be generated.

◆ getDigest()

OTPHP\OTPInterface::getDigest ( )
inherited
Return values
non-empty-stringDigest algorithm used to calculate the OTP. Possible values are 'md5', 'sha1', 'sha256' and 'sha512'

◆ getDigits()

OTPHP\OTPInterface::getDigits ( )
inherited
Return values
positive-intNumber of digits in the OTP

◆ getIssuer()

OTPHP\OTPInterface::getIssuer ( )
inherited
Return values
non-empty-string|nullThe issuer

◆ getLabel()

OTPHP\OTPInterface::getLabel ( )
inherited
Return values
non-empty-string|nullThe label of the OTP

◆ getParameter()

OTPHP\OTPInterface::getParameter ( string $parameter)
inherited
Parameters
non-empty-string$parameter

◆ getParameters()

OTPHP\OTPInterface::getParameters ( )
inherited
Return values
array<non-empty-string,mixed>

◆ getPeriod()

OTPHP\TOTPInterface::getPeriod ( )

Get the period of time for OTP generation (a non-null positive integer, in second).

Implemented in OTPHP\TOTP.

◆ getProvisioningUri()

OTPHP\OTPInterface::getProvisioningUri ( )
inherited

Get the provisioning URI.

Return values
non-empty-string

Implemented in OTPHP\TOTP.

◆ getQrCodeUri()

OTPHP\OTPInterface::getQrCodeUri ( string $uri,
string $placeholder )
inherited

Get the provisioning URI.

Parameters
non-empty-string$uriThe Uri of the QRCode generator with all parameters. This Uri MUST contain a placeholder that will be replaced by the method.
non-empty-string$placeholderthe placeholder to be replaced in the QR Code generator URI

Implemented in OTPHP\OTP.

◆ getSecret()

OTPHP\OTPInterface::getSecret ( )
inherited
Return values
non-empty-stringThe secret of the OTP

◆ hasParameter()

OTPHP\OTPInterface::hasParameter ( string $parameter)
inherited
Parameters
non-empty-string$parameter

◆ isIssuerIncludedAsParameter()

OTPHP\OTPInterface::isIssuerIncludedAsParameter ( )
inherited
Return values
boolIf true, the issuer will be added as a parameter in the provisioning URI

◆ now()

OTPHP\TOTPInterface::now ( )

Return the TOTP at the current time.

Return values
non-empty-string

Implemented in OTPHP\TOTP.

◆ setDigest()

OTPHP\OTPInterface::setDigest ( string $digest)
inherited
Parameters
non-empty-string$digest

◆ setIssuer()

OTPHP\OTPInterface::setIssuer ( string $issuer)
inherited
Parameters
non-empty-string$issuer

◆ setLabel()

OTPHP\OTPInterface::setLabel ( string $label)
inherited
Parameters
non-empty-string$labelThe label of the OTP

◆ setParameter()

OTPHP\OTPInterface::setParameter ( string $parameter,
mixed $value )
inherited
Parameters
non-empty-string$parameter

◆ setSecret()

OTPHP\OTPInterface::setSecret ( string $secret)
inherited
Parameters
non-empty-string$secret

◆ verify()

OTPHP\OTPInterface::verify ( string $otp,
null|int $input = null,
null|int $window = null )
inherited

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.

Parameters
non-empty-string$otp
null | 0 | positive-int$input
null | 0 | positive-int$window

Implemented in OTPHP\TOTP.


The documentation for this interface was generated from the following file: