Discuss this help topic in SecureBlackbox Forum
Save the OpenPGP keys and keyrings
There are two different ways of saving keys to files. The first method is based on SaveToFile() methods provided by TElPGPPublicKey and TElPGPSecretKey components. This can be thought of as 'exporting' keys, i.e. creating a copy of a standalone public or secret key that is supposed to be imported later by some other software:
publicKey.SaveToFile("LukesPublicKey.asc", true);The Armor parameter (which is set to true in the above call) specifies that Base64 armoring should be applied to the key before it is saved to the file. Armouring makes OpenPGP keys, which are binary by their nature, friendlier to the text-based transports. Particularly, you can paste an armored OpenPGP key straight into your e-mail message and be sure that it won't be corrupted while in transit.
To save the secret key to file or data stream, use SaveToFile() and SaveToStream() methods of TElPGPSecretKey class. You can save the key to the file on the disk or to the stream (be it file stream, or memory stream, or BLOB stream or some other stream).
In order to be able to read the saved key using old PGP software (PGP 2.6, old versions of GnuPG etc.) you need to save the key in old format. To do this, set UseOldPackets property of TElPGPCustomSecretKey class to true. You may need to also set WriteOldPrefix property TElPGPSecretKey class to true.
To save the public key to file or data stream use SaveToFile() and SaveToStream() methods of TElPGPPublicKey class. You can save the key to the file on the disk or to the stream (be it file stream, or memory stream, or BLOB stream or some other stream).
In order to be able to read the saved key using old PGP software (PGP 2.6, old versions of GnuPG etc.) you need to save the key in old format. To do this, set UseOldPackets property of TElPGPCustomPublicKey class to true. You may need to also set WriteOldPrefix property of TElPGPPublicKey class to true.
The other method is based on functionality provided by TElPGPKeyring component. It can be used if you need to save the key together with some other keys, or if you are storing the key for yourself and do not have plans on importing it to any other software (keyring-based method of storing keys omits some meta information about them). Still, please keep in mind that certain third-party software may be unable to process properly exported keys and might require the keyring format to be used when importing keys.
To save the keyring to file or data stream, use Save() method of TElPGPKeyring class. You can save the keyring to the files on the disk or to the streams (be it file stream, or memory stream, or BLOB stream or some other stream).
You need to pass the files (or streams) for public and secret keys to Save() method. If you want to save only public or only secret keys, pass only the name of the needed file or the reference to the needed stream. Leave the other parameter empty.
When you save the keyring or the key, you can specify, whether the resulting data should be armored, using Armor property of the corresponding class. Read more about armoring in the corresponding how-to article.