encryptDirect method
Encrypts a message directly using the derived key.
Returns an EncryptedBuffer containing the encrypted message.
Implementation
EncryptedBuffer encryptDirect({
required KeyAlgorithm encryptionAlgorithm,
required Key recipientKey,
required Key ephemeralKey,
required Uint8List message,
Uint8List? aad,
Uint8List? nonce,
}) {
final derived = deriveKey(
encryptionAlgorithm: encryptionAlgorithm,
ephemeralKey: ephemeralKey,
recipientKey: recipientKey,
receive: false,
);
final encryptedBuffer = derived.aeadEncrypt(message: message, aad: aad, nonce: nonce);
derived.handle.free();
return encryptedBuffer;
}