NET PGP Library
PgpVersion Property
Example 



KellermanSoftware.NetPgpLibrary Namespace > PgpEncryptorDecryptor Class : PgpVersion Property
Which PGP Version to use. In PGP version 2 the symmetric key algorithm is IDEA. In PGP Version 3 it uses CAST-128 (a.k.a. CAST5) symmetric key algorithm. The default is Version 3.
Syntax
'Declaration
 
Public Property PgpVersion As PgpVersion
'Usage
 
Dim instance As PgpEncryptorDecryptor
Dim value As PgpVersion
 
instance.PgpVersion = value
 
value = instance.PgpVersion
public PgpVersion PgpVersion {get; set;}
public:
property PgpVersion PgpVersion {
   PgpVersion get();
   void set (    PgpVersion value);
}
Example
PgpEncryptorDecryptor pgpEncryptorDecryptor = new PgpEncryptorDecryptor(); //Trial Mode
//PgpEncryptorDecryptor pgpEncryptorDecryptor = new PgpEncryptorDecryptor("place user name here", "place license key here"); //License Mode
 
//Use PGP Version 2 instead of the default PGP Version 3
pgpEncryptorDecryptor.PgpVersion = PgpVersion.Version2;
 
// we need to generate the keys first if we haven't got them already
string username = "username";
string password = "password";
string directoryForKeys = Directory.GetCurrentDirectory();
string publicKeyFilePath = Path.Combine(directoryForKeys, "public.asc");
string privateKeyFilePath = Path.Combine(directoryForKeys, "private.asc");
 
pgpEncryptorDecryptor.GenerateKeyPairFiles(username, password, publicKeyFilePath, privateKeyFilePath);
 
//Create a test file
string directoryForFiles = Directory.GetCurrentDirectory();
string inputFilePath = Path.Combine(directoryForFiles, "input.txt");
File.WriteAllText(inputFilePath, "This is a test");
 
string encryptedFilePath = Path.Combine(directoryForFiles, "encrypted.pgp");
bool armor = true;
 
pgpEncryptorDecryptor.EncryptFile(inputFilePath, encryptedFilePath, publicKeyFilePath, armor);
 
// decrypt file         
string decryptedFilePath = Path.Combine(directoryForFiles, "decrypted.txt");
pgpEncryptorDecryptor.DecryptFile(encryptedFilePath, decryptedFilePath, privateKeyFilePath, "password");
Dim pgpEncryptorDecryptor As New PgpEncryptorDecryptor() 'Trial Mode
'Dim pgpEncryptorDecryptorLicensed As New PgpEncryptorDecryptor("place user name here", "place license key here") //License Mode
 
'Use PGP Version 2 instead of the default PGP Version 3
pgpEncryptorDecryptor.PgpVersion = PgpVersion.Version2
 
' we need to generate the keys first if we haven't got them already
Dim username As String = "username"
Dim password As String = "password"
Dim directoryForKeys As String = Directory.GetCurrentDirectory()
Dim publicKeyFilePath As String = Path.Combine(directoryForKeys, "public.asc")
Dim privateKeyFilePath As String = Path.Combine(directoryForKeys, "private.asc")
 
pgpEncryptorDecryptor.GenerateKeyPairFiles(username, password, publicKeyFilePath, privateKeyFilePath)
 
'Create a test file
Dim directoryForFiles As String = Directory.GetCurrentDirectory()
Dim inputFilePath As String = Path.Combine(directoryForFiles, "input.txt")
File.WriteAllText(inputFilePath, "This is a test")
 
Dim encryptedFilePath As String = Path.Combine(directoryForFiles, "encrypted.pgp")
Dim armor As Boolean = True
 
pgpEncryptorDecryptor.EncryptFile(inputFilePath, encryptedFilePath, publicKeyFilePath, armor)
 
' decrypt file         
Dim decryptedFilePath As String = Path.Combine(directoryForFiles, "decrypted.txt")
pgpEncryptorDecryptor.DecryptFile(encryptedFilePath, decryptedFilePath, privateKeyFilePath, "password")
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

PgpEncryptorDecryptor Class
PgpEncryptorDecryptor Members