Encrypt a file with a password
Password-based encryption is a convenient way of exchanging information securely with someone who does not have an OpenPGP key pair. SecureBlackbox supports such encryption through a dedicated encryption mode of TElPGPWriter component.
TElPGPWriter writer = new TElPGPWriter();
pgpWriter.EncryptionType = SBPGP.TSBPGPEncryptionType.etPassphrase;
pgpWriter.Filename = "picture.jpg"; pgpWriter.Timestamp = DateTime.UtcNow;Note: an empty string assigned to the Filename property will make the components create a for-your-eyes-only file, which won't be decrypted to a persistent media.
pgpWriter.SymmetricKeyAlgorithm = SBPGPConstants.Unit.SB_PGP_ALGORITHM_SK_AES256;Note: in default configuration, TElPGPWriter comes with its own pre-defined encryption settings (CAST5 with 128 bit key, on the date of creation of this article).
pgpWriter.Armor = true; pgpWriter.Compress = true;