Skip to content

PGP Decrypt File

ts
// Decrypt a file using the recipient's private key
var ok = 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

Return valueExplanation
trueDecryption succeeded
falseDecryption failed (file not found, invalid key, corrupt data, etc.)

WARNING

The recipient's private key is required for decryption. Make sure to keep your private key secure and never include it directly in script source code. Use GetSecret to retrieve key paths or passphrases at runtime instead.

Example

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