Generates OpenPGP Key pair (public and private key) with no expiration date.
The newly generated key is stored in this KeyStore instance.
Namespace: DidiSoft.PgpThe newly generated key is stored in this KeyStore instance.
Assembly: DidiSoft.Pgp (in DidiSoft.Pgp.dll) Version: 1.7.3.35547
Syntax
| C# |
|---|
public virtual KeyPairInformation GenerateKeyPair( int keySize, string userId, KeyAlgorithm keyAlgorithm, string password, CompressionAlgorithm[] compressionTypes, HashAlgorithm[] hashingAlgorithmTypes, CypherAlgorithm[] cipherTypes ) |
| Visual Basic |
|---|
Public Overridable Function GenerateKeyPair ( _ keySize As Integer, _ userId As String, _ keyAlgorithm As KeyAlgorithm, _ password As String, _ compressionTypes As CompressionAlgorithm(), _ hashingAlgorithmTypes As HashAlgorithm(), _ cipherTypes As CypherAlgorithm() _ ) As KeyPairInformation |
| Visual C++ |
|---|
public: virtual KeyPairInformation^ GenerateKeyPair( int keySize, String^ userId, KeyAlgorithm keyAlgorithm, String^ password, array<CompressionAlgorithm>^ compressionTypes, array<HashAlgorithm>^ hashingAlgorithmTypes, array<CypherAlgorithm>^ 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: DidiSoft.Pgp..::..KeyAlgorithm
Key algorithm. Possible values: ELGAMAL, RSA
- password
- Type: System..::..String
Secret key password
- compressionTypes
- Type: array<DidiSoft.Pgp..::..CompressionAlgorithm>[]()[][]
Array of compression algorithms supported by the key.
- hashingAlgorithmTypes
- Type: array<DidiSoft.Pgp..::..HashAlgorithm>[]()[][]
Array of hashing algorithms supported by the key.
- cipherTypes
- Type: array<DidiSoft.Pgp..::..CypherAlgorithm>[]()[][]
Array of symmetric encryption algorithms supported by the key.
Return Value
KeyPairInformation class representing the generated key pair
Remarks
Note: for key size larger than 2048 bits key generation will take a few moments.
Examples
using System; using DidiSoft.Pgp; public class GenerateKeyPairRSA { public static void Demo() { KeyStore ks = new KeyStore(@"DataFiles\key.store", "changeit"); String userId = "demo2@didisoft.com"; String privateKeyPassword = "changeit"; HashAlgorithm[] hashingAlgorithm = {HashAlgorithm.MD5, HashAlgorithm.SHA1}; CompressionAlgorithm[] compression = {CompressionAlgorithm.ZIP, CompressionAlgorithm.ZLIB}; SymmetricAlgorithm[] cypher = {SymmetricAlgorithm.CAST5}; ks.GenerateKeyPair( 1024, userId, KeyAlgorithm.RSA, privateKeyPassword, compression, hashingAlgorithm, cypher); } }
Imports System Imports DidiSoft.Pgp Public Class GenerateKeyPairRSA Public Shared Sub Demo() Dim ks As New KeyStore("DataFiles\key.store", "changeit") Dim userId As String = "demo2@didisoft.com" Dim privateKeyPassword As String = "changeit" Dim hashingAlgorithm As HashAlgorithm = {HashAlgorithm.MD5, HashAlgorithm.SHA1} Dim compression() As CompressionAlgorithm = {CompressionAlgorithm.ZIP, CompressionAlgorithm.ZLIB} Dim cypher() As SymmetricAlgorithm = {SymmetricAlgorithm.CAST5} ks.GenerateKeyPair( 1024, _ userId, _ KeyAlgorithm.RSA, _ privateKeyPassword, _ compression, _ hashingAlgorithm, _ cypher) End Sub End Class