private function validHmac($hmac, $compareHmac)
    {
        if(function_exists("hash_equals")) {
            return hash_equals($hmac, $compareHmac);
        }

        $hashLength = mb_strlen($hmac, '8bit');
        $compareLength = mb_strlen($compareHmac, '8bit');

        if ($hashLength !== $compareLength) {
            return false;
        }

        $result = 0;

        for ($i = 0; $i < $hashLength; $i++) {
            $result |= (ord($hmac[$i]) ^ ord($compareHmac[$i]));
        }

        return $result === 0;
    }