PGP Encrypt File
ts
// Encrypt a file for a recipient using their public key
var err = PGPEncryptFile(
"/documents/confidential.pdf", // Input file
"/transfer/confidential.pdf.pgp", // Output encrypted file
"/keys/bob.pubkey" // Recipient's public key
);Encrypts a file using the recipient's PGP public key. The output is an armored, encrypted file suitable for secure transfer.
Parameters
| Name | Type | Description |
|---|---|---|
| inputFile | string | Path to the file to encrypt |
| outputFile | string | Path for the resulting encrypted file |
| recipientPubKey | string | Path to the recipient's public key file |
Returns
- Returns
nullon success, or an error object if encryption fails.
NOTE
Only the recipient's public key is required for encryption. The sender's private key is not needed for basic encryption.
Example
ts
var err = PGPEncryptFile(
"/data/budget.xlsx",
"/data/budget.xlsx.pgp",
"/keys/bob.pubkey"
);
if (err == null) {
Log("File encrypted successfully!");
} else {
Log("Encryption failed: " + err);
}