def verify(self, msg, sig, key):
        """
        Verifies whether sig is the correct message authentication code of data.

        :param msg: The data
        :param sig: The message authentication code to verify against data.
        :param key: The key to use
        :return: Returns true if the mac was valid otherwise it will raise an
            Exception.
        """
        try:
            h = hmac.HMAC(key, self.algorithm(), default_backend())
            h.update(msg)
            h.verify(sig)
            return True
        except:
            return False
def verify ( self , msg , sig , key ) : try : h = hmac . HMAC ( key , self . algorithm ( ) , default_backend ( ) ) h . update ( msg ) h . verify ( sig ) return True except : return False
Verifies whether sig is the correct message authentication code of data.

        :param msg: The data
        :param sig: The message authentication code to verify against data.
        :param key: The key to use
        :return: Returns true if the mac was valid otherwise it will raise an
            Exception.