Set cypher
We can change the preferred symmetric encryption algorithm (cypher) used by DidiSoft OpenPGP Library for .NET through the Cypher property of the class PGPLib . By default CAST 5 is used.
Have in mind that although you have changed this property, the library will ignore it if the public key used for encryption does not list this algorithm in it’s preferred cyphers list (each OpenPGP public key holds such an information internally in a special signature). In that case the library will automatically pick the first algorithm from the public key list.
Below is a list of the supported symmetric key algorithms:
CypherAlgorithm.TRIPLE_DES CypherAlgorithm.CAST5 CypherAlgorithm.BLOWFISH CypherAlgorithm.AES_128 CypherAlgorithm.AES_192 CypherAlgorithm.AES_256 CypherAlgorithm.TWOFISH CypherAlgorithm.DES CypherAlgorithm.SAFER CypherAlgorithm.IDEA
Commercial usage of IDEA requires licensing from MediaCrypt (US patent expiring January 7, 2012)
The example below demonstrates how to set explicitly a preferred symmetric encryption algorithm for an instance of the library:
C#
PGPLib pgp = new PGPLib(); pgp.Cypher = CypherAlgorithm.AES_128;
VB.NET
Dim pgp As New PGPLib() pgp.Cypher = CypherAlgorithm.AES_128
The change has effect only on the current instance of the library and will have effect on subsequent calls to all Encrypt and SignAndEncrypt methods.