Generates OpenPGP Key pair (public and private key).
The newly generated key is stored in this KeyStore instance.

Namespace:  DidiSoft
Assembly:  PGPLib (in PGPLib.dll) Version: 1.6.3.19546

Syntax

C#
public virtual void GenerateKeyPair(
	int keySize,
	string userId,
	string keyAlgorithm,
	string password,
	string compressionTypes,
	string hashingAlgorithmTypes,
	string cipherTypes
)
Visual Basic (Declaration)
Public Overridable Sub GenerateKeyPair ( _
	keySize As Integer, _
	userId As String, _
	keyAlgorithm As String, _
	password As String, _
	compressionTypes As String, _
	hashingAlgorithmTypes As String, _
	cipherTypes As String _
)
Visual C++
public:
virtual void GenerateKeyPair(
	int keySize, 
	String^ userId, 
	String^ keyAlgorithm, 
	String^ password, 
	String^ compressionTypes, 
	String^ hashingAlgorithmTypes, 
	String^ cipherTypes
)

Parameters

keySize
Type: System..::.Int32
Size of the keys
userId
Type: System..::.String
User Id of the form "name (comment) <email address>"
keyAlgorithm
Type: System..::.String
Key algorithm. Possible values: ELGAMAL, RSA
password
Type: System..::.String
Secret key password
compressionTypes
Type: System..::.String
Compression algorithms supported by the key.
Comma separated list of one or more of: ZLIB, ZIP, UNCOMPRESSED, BZIP2
hashingAlgorithmTypes
Type: System..::.String
Hashing algorithms supported by the key.
Comma separated list of one or more of: SHA256, SHA384, SHA512, SHA224, SHA1, MD5, RIPEMD160, MD2
cipherTypes
Type: System..::.String
Symmetric algorithms supported by the key.
Comma separated list of one or more of: TRIPLE_DES, CAST5, BLOWFISH, AES_128, AES_192, AES_256, TWOFISH, DES, SAFER

Remarks

Note: for key size larger than 2048 bits key generation will take a few moments.

Examples

CopyC#
using System;
using DidiSoft;

public class GenerateKeyPair2
{
   public static void Demo()
   {
       KeyStore ks = new KeyStore(@"DataFiles\key.store", "changeit");

       String keyAlgorithm = "RSA"; 
       String userId = "demo2@didisoft.com";
       String hashingAlgorithm = "SHA1, MD5";
       String compression = "ZLib, ZIP";
       String cypher = "CAST5";
       String privateKeyPassword = "changeit";

       ks.GenerateKeyPair( 1024, 
                           userId, 
                           keyAlgorithm, 
                           privateKeyPassword, 
                           compression, 
                           hashingAlgorithm, 
                           cypher);        
   }
}
CopyVB.NET
Imports System
Imports DidiSoft

Public Class GenerateKeyPair2
   Public Shared Sub Demo()
       Dim ks As New KeyStore("DataFiles\key.store", "changeit")

       Dim keyAlgorithm As String = "RSA"
       Dim userId As String = "demo2@didisoft.com"
       Dim hashingAlgorithm As String = "SHA1, MD5"
       Dim compression As String = "ZLib, ZIP"
       Dim cypher As String = "CAST5"
       Dim privateKeyPassword As String = "changeit"

       ks.GenerateKeyPair( 1024, _
                            userId, _
                            keyAlgorithm, _
                            privateKeyPassword, _
                            compression, _
                            hashingAlgorithm, _
                            cypher)
   End Sub
End Class

Exceptions

ExceptionCondition
PgpException

See Also