decrypt static method
Implementation
static Future<String> decrypt(WCEncryptionPayload payload, String key) async {
final data = hexToBytes(payload.data);
final _iv = hexToBytes(payload.iv);
final _keyBytes = hexToBytes(key);
final computedHmac = await _computeHmac(data, _iv, _keyBytes);
if (payload.hmac.toLowerCase() != bytesToHex(computedHmac.bytes)) {
throw HmacException();
}
final algorithm = AesCbc.with256bits(macAlgorithm: MacAlgorithm.empty);
final secretKey = SecretKey(_keyBytes);
final secretBox = SecretBox(data, nonce: _iv, mac: Mac.empty);
final clearText = await algorithm.decrypt(
secretBox,
secretKey: secretKey,
);
return utf8.decode(clearText);
}