PGP Encrypt File
ts
// Encrypt a file for a recipient using their public key
var ok = 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
| Return value | Explanation |
|---|---|
true | Encryption succeeded |
false | Encryption failed (file not found, invalid key, etc.) |
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 ok = PGPEncryptFile(
"/data/budget.xlsx",
"/data/budget.xlsx.pgp",
"/keys/bob.pubkey"
);
if (ok) {
Log("File encrypted successfully!");
} else {
Log("Encryption failed.");
}