encryptFile method

Future<void> encryptFile(
  1. String inputPath,
  2. String outputPath, {
  3. required List<EncryptionPublicKey> recipients,
  4. Map<String, String> context = const {},
  5. int chunkSize = defaultStreamChunkSize,
  6. ProgressCallback? onProgress,
  7. CancellationToken? cancel,
})

Encrypts inputPath into outputPath with bounded memory.

Output is written to a temporary file in the destination directory and renamed into place on success; on failure or cancellation the temporary file is deleted and outputPath is left untouched.

Implementation

Future<void> encryptFile(
  String inputPath,
  String outputPath, {
  required List<EncryptionPublicKey> recipients,
  Map<String, String> context = const {},
  int chunkSize = defaultStreamChunkSize,
  ProgressCallback? onProgress,
  CancellationToken? cancel,
}) => _writeAtomically(
  outputPath,
  encryptStream(
    File(inputPath).openRead(),
    recipients: recipients,
    context: context,
    chunkSize: chunkSize,
    onProgress: onProgress,
    cancel: cancel,
  ),
);