⇦ Back to Totp classMethod __construct
public
__construct
(mixed $timeStep = 30, mixed $passCodeLength = 6, mixed $secretLength = 10, mixed $base32 = null)
Initialises an RFC6238-compatible TOTP generator. Please note that this
class does not implement the constraint in the last paragraph of §5.2
of RFC6238. It's up to you to ensure that the same user/device does not
retry validation within the same Time Step.
Parameters
- int $timeStep The Time Step (in seconds). Use 30 to be compatible with Google Authenticator.
- int $passCodeLength The generated passcode length. Default: 6 digits.
- int $secretLength The length of the secret key. Default: 10 bytes (80 bits).
- object $base32 The base32 en/decrypter
Method __construct - Source code
/**
* Initialises an RFC6238-compatible TOTP generator. Please note that this
* class does not implement the constraint in the last paragraph of §5.2
* of RFC6238. It's up to you to ensure that the same user/device does not
* retry validation within the same Time Step.
*
* @param int $timeStep The Time Step (in seconds). Use 30 to be compatible with Google Authenticator.
* @param int $passCodeLength The generated passcode length. Default: 6 digits.
* @param int $secretLength The length of the secret key. Default: 10 bytes (80 bits).
* @param Object $base32 The base32 en/decrypter
*/
public function __construct($timeStep = 30, $passCodeLength = 6, $secretLength = 10, $base32 = null)
{
$this->_timeStep = $timeStep;
$this->_passCodeLength = $passCodeLength;
$this->_secretLength = $secretLength;
$this->_pinModulo = pow(10, $this->_passCodeLength);
if (\is_null($base32)) {
$this->_base32 = new Base32();
} else {
$this->_base32 = $base32;
}
}