public function generateCode($secret, $counter, $algorithm = 'sha512')
	{
		$key = $this->base32->decode($secret);

		if (empty($counter))
		{
			return '';
		}

		$hash = hash_hmac($algorithm, $this->getBinaryCounter($counter), $key, true);

		return str_pad($this->truncate($hash), $this->code_length, '0', STR_PAD_LEFT);
	}
public function generateCode($secret, $counter, $algorithm = 'sha512')
	{
		$key = $this->base32->decode($secret);

		if (empty($counter))
		{
			return '';
		}

		$hash = hash_hmac($algorithm, $this->getBinaryCounter($counter), $key, true);

		return str_pad($this->truncate($hash), $this->code_length, '0', STR_PAD_LEFT);
	}
public function generateCode ( $ secret , $ counter , $ algorithm = 'sha512' ) { $ key = $ this -> base32 -> decode ( $ secret ) ; if ( empty ( $ counter ) ) { return '' ; } $ hash = hash_hmac ( $ algorithm , $ this -> getBinaryCounter ( $ counter ) , $ key , true ) ; return str_pad ( $ this -> truncate ( $ hash ) , $ this -> code_length , '0' , STR_PAD_LEFT ) ; }
Generates code based on timestamp and secret

@param string $secret Secret shared with user
@param int $counter Counter for code generation
@param string $algorithm Algorithm to use for HMAC hash.
Defaults to sha512. The following hash types are allowed:
TOTP: sha1, sha256, sha512
HOTP: sha1

@return string Generated OTP code
Generates code based on timestamp and secret