encryptDirect method

EncryptedBuffer encryptDirect({
  1. required KeyAlgorithm encryptionAlgorithm,
  2. required Key recipientKey,
  3. required Key ephemeralKey,
  4. required Uint8List message,
  5. Uint8List? aad,
  6. Uint8List? nonce,
})

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;
}