Generates PGP Key pair (public and private key).
The newly generated key is stored in this KeyStore instance.
Namespace:
DidiSoftThe newly generated key is stored in this KeyStore instance.
Assembly: PGPLib (in PGPLib.dll) Version: 1.6.3.19546
Syntax
| C# |
|---|
public virtual void GenerateKeyPair( int keySize, string userId, KeyAlgorithm keyAlgorithm, string password, CompressionAlgorithm[] compressionTypes, HashAlgorithm[] hashingAlgorithmTypes, CypherAlgorithm[] cipherTypes, DateTime validToDate ) |
| Visual Basic (Declaration) |
|---|
Public Overridable Sub GenerateKeyPair ( _ keySize As Integer, _ userId As String, _ keyAlgorithm As KeyAlgorithm, _ password As String, _ compressionTypes As CompressionAlgorithm(), _ hashingAlgorithmTypes As HashAlgorithm(), _ cipherTypes As CypherAlgorithm(), _ validToDate As DateTime _ ) |
| Visual C++ |
|---|
public: virtual void GenerateKeyPair( int keySize, String^ userId, KeyAlgorithm keyAlgorithm, String^ password, array<CompressionAlgorithm>^ compressionTypes, array<HashAlgorithm>^ hashingAlgorithmTypes, array<CypherAlgorithm>^ cipherTypes, DateTime validToDate ) |
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..::.KeyAlgorithm
Key algorithm. Possible values: ELGAMAL, RSA
- password
- Type: System..::.String
Secret key password
- compressionTypes
- Type: array<
DidiSoft..::.CompressionAlgorithm
>[]()[]
Compression algorithms supported by the key.
Comma separated list of one or more of: ZLIB, ZIP, UNCOMPRESSED, BZIP2
- hashingAlgorithmTypes
- Type: array<
DidiSoft..::.HashAlgorithm
>[]()[]
Hashing algorithms supported by the key.
Comma separated list of one or more of: SHA256, SHA384, SHA512, SHA224, SHA1, MD5, RIPEMD160, MD2
- cipherTypes
- Type: array<
DidiSoft..::.CypherAlgorithm
>[]()[]
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
- validToDate
- Type: System..::.DateTime
Expiration Date for this key
Remarks
Note: for key size larger than 2048 bits key generation will take a few moments.
Examples
using System; using DidiSoft; public class GenerateKeyPair2 { 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}; DateTime validToDate = new DateTime(2011, 12, 31); ks.GenerateKeyPair( 1024, userId, KeyAlgorithm.RSA, privateKeyPassword, compression, hashingAlgorithm, cypher, validToDate); } }
Imports System Imports DidiSoft Public Class GenerateKeyPair2 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} Dim validToDate As New DateTime(2011, 12, 31) ks.GenerateKeyPair( 1024, _ userId, _ KeyAlgorithm.RSA, _ privateKeyPassword, _ compression, _ hashingAlgorithm, _ cypher, _ validToDate) End Sub End Class
Exceptions
| Exception | Condition |
|---|---|
| PgpException |