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;
    }
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;
    }
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 ; }
Validates if the provided hmac is equal to the expected hmac

@param   string      $hmac           Provided hmac
@param   string      $compareHmac    Expected hmac

@return boolean
Validates if the provided hmac is equal to the expected hmac