Skip to content

PGP Decrypt File

ts
// Decrypt a file using the recipient's private key
var err = PGPDecryptFile(
  "/transfer/confidential.pdf.pgp",   // Encrypted input file
  "/documents/confidential.pdf",      // Output decrypted file
  "/keys/bob.privkey"                 // Recipient's private key
);

Decrypts a file using the recipient's PGP private key. The output is the original, decrypted file.

Parameters

NameTypeDescription
inputFilestringPath to the encrypted file
outputFilestringPath for the resulting decrypted file
recipientPrivKeystringPath to the recipient's private key file

Returns

  • Returns null on success, or an error object if decryption fails.

WARNING

The recipient's private key is required for decryption. Make sure to keep your private key secure.

Example

ts
var err = PGPDecryptFile(
  "/data/budget.xlsx.pgp",
  "/data/budget.xlsx",
  "/keys/bob.privkey"
);
if (err == null) {
  Log("File decrypted successfully!");
} else {
  Log("Decryption failed: " + err);
}