Moodle PHP Documentation 5.1
Moodle 5.1dev (Build: 20250706) (a6b17d8f6bd)
OTPHP\OTP Class Reference
Inheritance diagram for OTPHP\OTP:
OTPHP\OTPInterface OTPHP\TOTP

Public Member Functions

 at (int $input)
 
 getDigest ()
 
 getDigits ()
 
 getIssuer ()
 
 getLabel ()
 
 getParameter (string $parameter)
 
 getParameters ()
 
 getProvisioningUri ()
 Get the provisioning URI.
 
 getQrCodeUri (string $uri, string $placeholder)
 Get the provisioning URI.
 
 getSecret ()
 
 hasParameter (string $parameter)
 
 isIssuerIncludedAsParameter ()
 
 setDigest (string $digest)
 
 setDigits (int $digits)
 
 setIssuer (string $issuer)
 
 setIssuerIncludedAsParameter (bool $issuer_included_as_parameter)
 
 setLabel (string $label)
 
 setParameter (string $parameter, mixed $value)
 
 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 createFromSecret (string $secret)
 
static generate ()
 Create a new OTP object.
 

Public Attributes

const DEFAULT_DIGEST = 'sha1'
 
const DEFAULT_DIGITS = 6
 

Protected Member Functions

 __construct (string $secret)
 
 compareOTP (string $safe, string $user)
 
 filterOptions (array &$options)
 
 generateOTP (int $input)
 The OTP at the specified input.
 
 generateURI (string $type, array $options)
 

Static Protected Member Functions

static generateSecret ()
 

Member Function Documentation

◆ at()

OTPHP\OTP::at ( int $input)
Parameters
0 | positive-int$input

Implements OTPHP\OTPInterface.

Reimplemented in OTPHP\TOTP.

◆ compareOTP()

OTPHP\OTP::compareOTP ( string $safe,
string $user )
protected
Parameters
non-empty-string$safe
non-empty-string$user

◆ filterOptions()

OTPHP\OTP::filterOptions ( array & $options)
protected
Parameters
array<non-empty-string,mixed>$options

Reimplemented in OTPHP\TOTP.

◆ generate()

static OTPHP\OTPInterface::generate ( )
staticinherited

Create a new OTP object.

A random 64 bytes secret will be generated.

◆ generateOTP()

OTPHP\OTP::generateOTP ( int $input)
protected

The OTP at the specified input.

Parameters
0 | positive-int$input
Return values
non-empty-string

◆ generateSecret()

static OTPHP\OTP::generateSecret ( )
staticfinalprotected
Return values
non-empty-string

◆ generateURI()

OTPHP\OTP::generateURI ( string $type,
array $options )
protected
Parameters
non-empty-string$type
array<non-empty-string,mixed>$options
Return values
non-empty-string

◆ 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>

◆ getProvisioningUri()

OTPHP\OTPInterface::getProvisioningUri ( )
inherited

Get the provisioning URI.

Return values
non-empty-string

Implemented in OTPHP\TOTP.

◆ getQrCodeUri()

OTPHP\OTP::getQrCodeUri ( string $uri,
string $placeholder )

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

Implements OTPHP\OTPInterface.

◆ 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

◆ 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 class was generated from the following file: