Skip to content

PGPSignFile (create a detached signature)

ts
function PGPSignFile(
  inFile:      string,  // required
  sigFile:     string,  // required
  pubKeyFile:  string,  // required
  privKeyFile: string   // required
): boolean;

NOTE

This function is available as of Syncplify Server! v7.1.1. If you are running an older version, upgrade to v7.1.1 or later to use it.

Creates a detached PGP signature for inFile and writes it to sigFile. The signature can later be verified by a recipient who holds the corresponding public key, confirming that the file was signed by you and has not been modified.

This is distinct from encryption: the file itself is not encrypted. Only the signature file is generated.

ParameterTypeRequirementExplanation
inFilestringrequiredFully qualified path to the file to sign
sigFilestringrequiredFully qualified path where the detached signature will be written
pubKeyFilestringrequiredPath to the signer's PGP public key file
privKeyFilestringrequiredPath to the signer's PGP private key file
Return valueExplanation
trueSignature was created successfully
falseSigning failed (missing file, invalid key, etc.)

NOTE

The recipient verifies the signature using the signer's public key. The signer's private key is kept secret and never shared.

Example

ts
var ok = PGPSignFile(
  '/var/outbox/report.csv',
  '/var/outbox/report.csv.sig',
  '/keys/sender.pubkey',
  '/keys/sender.privkey'
);
if (ok) {
  Log('File signed successfully.');
} else {
  Log('Signing failed.');
}

TIP

To generate a PGP key pair, use GeneratePGPKeys. To verify a signature produced by PGPSignFile, use PGPVerifyFile.