wcV1Encrypt function
Encrypt plaintext (a UTF-8 string, typically JSON) under key32.
Implementation
WcV1Payload wcV1Encrypt({
required Uint8List key32,
required Uint8List iv16,
required String plaintext,
}) {
final ct = aes256CbcEncrypt(
key32,
iv16,
Uint8List.fromList(utf8.encode(plaintext)),
);
final mac = hmacSha256(key32, _concat(ct, iv16));
return WcV1Payload(
data: hexEncode(ct),
hmac: hexEncode(mac),
iv: hexEncode(iv16),
);
}