def isValidHMAC(hmac1, hmac2, key):
 assert (len(hmac1) == len(hmac2))
 doubleHmac1 = mycrypto.HMAC_SHA256_128(key, hmac1)
 doubleHmac2 = mycrypto.HMAC_SHA256_128(key, hmac2)
 if (doubleHmac1 != doubleHmac2):
  return False
 log.debug('The computed HMAC is valid.')
 return True

def isValidHMAC ( hmac1 , hmac2 , key ) : assert ( len ( hmac1 ) == len ( hmac2 ) ) doubleHmac1 = mycrypto . HMAC_SHA256_128 ( key , hmac1 ) doubleHmac2 = mycrypto . HMAC_SHA256_128 ( key , hmac2 ) if ( doubleHmac1 != doubleHmac2 ) : return False log . debug ( 'The computed HMAC is valid.' ) return True
compares hmac1 and hmac2 after hmacing them again using key .