decryptFile method

Future<void> decryptFile(
  1. String inputPath,
  2. String outputPath, {
  3. required EncryptionPrivateKey privateKey,
  4. Map<String, String>? requiredContext,
  5. ProgressCallback? onProgress,
  6. CancellationToken? cancel,
})

Decrypts inputPath into outputPath.

Plaintext goes to a temporary file in the destination directory and is published (renamed to outputPath) only after the final chunk has been authenticated. On any failure the temporary file is deleted, so a truncated or tampered input never produces an output file.

The temporary and output files are created with the process's default permissions (umask). On a shared host, make the destination directory private if other local users must not read the plaintext.

Implementation

Future<void> decryptFile(
  String inputPath,
  String outputPath, {
  required EncryptionPrivateKey privateKey,
  Map<String, String>? requiredContext,
  ProgressCallback? onProgress,
  CancellationToken? cancel,
}) => _writeAtomically(
  outputPath,
  decryptStream(
    File(inputPath).openRead(),
    privateKey: privateKey,
    requiredContext: requiredContext,
    onProgress: onProgress,
    cancel: cancel,
  ),
);