encrypt static method
Encrypts the given value using the given public key.
Implementation
static Uint8List encrypt(Uint8List value, PublicKey publicKey) {
ECDHResult enc = ECDHCrypt.encrypt(value, publicKey: publicKey);
String mac = PDUtil.byteToHex(PDUtil.hmacMd5(enc.data, enc.key));
int originalDataLength = value.length;
int originalDataLengthIncPadLength =
(originalDataLength % 16) == 0 ? 0 : 16 - (originalDataLength % 16);
EciesData keyData = EciesData(
publicKey: enc.publicKey,
mac: PDUtil.hexToBytes(mac),
encryptedData: enc.data,
originalDataLength: originalDataLength,
originalDataLengthIncPadding: originalDataLengthIncPadLength);
return EciesCoding.encodeToBytes(keyData);
}