public function validate($totp, $key, $stamp = null)
    {
        if ($stamp === null) {
            $stamp = $this->timeManager->getCurrentStamp();
        }

        if (!preg_match('/^[0-9]{6}$/', $totp)) {
            return false;
        }
        $totp = intval($totp);

        // Search the stamp corresponding to the totp provided
        for ($st = $stamp - $this->window; $st <= $stamp + $this->window; ++$st) {
            if (($res = TOTPGenerator::generate($st, $key)) == $totp) {
                return $st;
            }
        }

        return false;
    }
public function validate($totp, $key, $stamp = null)
    {
        if ($stamp === null) {
            $stamp = $this->timeManager->getCurrentStamp();
        }

        if (!preg_match('/^[0-9]{6}$/', $totp)) {
            return false;
        }
        $totp = intval($totp);

        // Search the stamp corresponding to the totp provided
        for ($st = $stamp - $this->window; $st <= $stamp + $this->window; ++$st) {
            if (($res = TOTPGenerator::generate($st, $key)) == $totp) {
                return $st;
            }
        }

        return false;
    }
public function validate ( $ totp , $ key , $ stamp = null ) { if ( $ stamp === null ) { $ stamp = $ this -> timeManager -> getCurrentStamp ( ) ; } if ( ! preg_match ( '/^[0-9]{6}$/' , $ totp ) ) { return false ; } $ totp = intval ( $ totp ) ; // Search the stamp corresponding to the totp provided for ( $ st = $ stamp - $ this -> window ; $ st <= $ stamp + $ this -> window ; ++ $ st ) { if ( ( $ res = TOTPGenerator :: generate ( $ st , $ key ) ) == $ totp ) { return $ st ; } } return false ; }
Check if a totp corresponds to a key and a stamp.

@param string $key
@param int    $totp

@return bool Return true if the totp corresponds to the key and the stamp provided
Check if a totp corresponds to a key and a stamp .