Sign the data (common)
To sign the data using PGP algorithms, you need to use TElPGPWriter class.
First you need to specify the keys, which will be used for signing. This is done by setting the SigningKeys property of TElPGPWriter class to reference the instance of TElPGPKeyring class, which contains the keys. Note, that all keys will be used for signing, so if your keyring contains more keys, than you plan to use, then you need to copy the keys to other keyring. Remember, that when the data is signed, the private (secret, in PGP terms) keys are used, so you need to load the secret keyring to TElPGPKeyring.
When the keys are used the password for the key might be needed. TElPGPWriter asks the application for a password using OnKeyPassphrase event. You need to provide a handler for this event in order to supply TElPGPWriter with a password. Alternatively put the password to Passphrase property of the TElPGPSecretKey class.
Finally, call Sign() or ClearTextSign() method of TElPGPWriter class to process the data. ClearTextSign() creates a text signature over clear text data, without armoring or compressing the data before signing.
Detached parameter of Sign() method is used to create detached signatures. The detached signature doesn't contain the data being signed.
If you want the saved data to be readable using old PGP software (PGP 2.6, old versions of GnuPG etc.) you need to save the data in old format. To do this, set UseOldPackets property of TElPGPWriter class to true and UseNewFeatures property of TElPGPWriter to false. Set these properties before calling Sign() or ClearTextSign() method.