|
Decrypt and verify the data
As you rarely know, what kind of data (encrypted, signed, compressed, armored) your encoded stream contains,
ElPGPReader class attempts to perform all operations within one method call.
When processing the data, ElPGPReader extracts certain information from the encoded data.
It notifies the application about this information via its events such as
OnArmored,
OnCompressed,
OnEncrypted,
OnSigned.
These events are informational and used for notification only.
To decrypt and verify the data
-
Create an instance of ElPGPKeyring class.
This class will hold the keys, used to decrypt or verify the data.
Remember, that if you expect the data to be both signed and encrypted, you need to create 2 different keyrings (see below).
-
Load the keys into the keyring using Load() method of ElPGPKeyring class.
If you use the keys for decryption, you need to load only private keyring.
If you use the keys for signature verification, you only need public keys.
-
Set DecryptingKeys property of ElPGPReader class, if you expect to perform decryption.
-
If you know, that the encoded data is encrypted with the key(s) and you know the password for the secret key(s) used,
you can set KeyPassphrase property of ElPGPReader class.
The alternative way is to create an event handler for OnKeyPassphrase event
of ElPGPReader class and ask the user for the secret key passphrase in the event handler.
-
If you know, that the encoded data was encrypted using the password(s), set
Passphrase property
of ElPGPReader class to the passphrase, suitable for data decryption.
The alternative way is to create an event handler for
OnPassphrase event of
ElPGPReader class and ask the user for the passphrase in the event handler.
-
Set VerifyingKeys property of ElPGPReader,
if you expect to perform signature verification.
-
(Optionally) create an event handler for OnSignatures event of ElPGPReader class.
This event is used by the component to inform the application about signature verification result.
-
Create a stream for the decoded data and set OutputStream property of ElPGPReader.
If you expect multiple data blocks (files) to be present, create an event handler for OnCreateOutputStream
event of ElPGPReader class and create the stream in the event handler.
-
Call DecryptAndVerify() method of ElPGPReader class.
|