verifyHMAC method

Future<bool> verifyHMAC(
  1. String content,
  2. String hmac,
  3. String password
)

Implementation

Future<bool> verifyHMAC(String content, String hmac, String password) async {
  cryptography.SecretKey secretKey;
  if (password == '') {
    secretKey = cryptography.SecretKey(utf8.encode(defaultPassword));
  } else {
    secretKey = cryptography.SecretKey(utf8.encode(password));
  }

  var input = utf8.encode(content);
  final hmacAlgo = cryptography.Hmac.sha512();
  var mac = await hmacAlgo.calculateMac(input, secretKey: secretKey);
  return ListEquality().equals(hexToBytes(hmac), mac.bytes);
}