Skip to content

PGP encrypt file

ts
function PGPEncryptFile(
  inFile:  string,
  outFile: string,
  pubKey:  string,
  privKey: string
): boolean;

This function encrypts a file using OpenPGP; this function accepts the following parameters:

ParameterTypeRequirementExplanation
inFilestringrequiredthis is the full path and name to the file that you wish to encrypt
outFilestringrequiredthis is the full path and name of the resulting encrypted file you wish to generate
pubKeystringrequiredthe full path and name to a file containing the recipient’s PGP public key
privKeystringrequiredthe full path and name to a file containing the sender’s PGP private key

Possible return values:

ValueExplanation
truethe function succeeded: the file was encrypted
truethe function failed: the file was not encrypted

Example

ts
{
  PGPEncryptFile('C:\\Data\\budget.xlsx', 'C:\\Encrypted\\budget.xlsx.pgp',
    'C:\\PGPKeys\\Bob.pubkey', 'C:\\PGPKeys\\Alice.privkey');
}