Imports and OpenPGP private key into a custom OpenPGP key store.

Namespace: DidiSoft.Pgp
Assembly: DidiSoft.Pgp (in DidiSoft.Pgp.dll) Version: 1.7.3.35547

Syntax

C#
public KeyPairInformation ImportPrivateKey(
	string privateKeyFileName
)
Visual Basic
Public Function ImportPrivateKey ( _
	privateKeyFileName As String _
) As KeyPairInformation
Visual C++
public:
KeyPairInformation^ ImportPrivateKey(
	String^ privateKeyFileName
)

Parameters

privateKeyFileName
Type: System..::..String
File of the Private key to be imported (absolute or relative path)

Return Value

A KeyPairInformation object representing the imported private key

Remarks

If the key store does not exist, it is created.

Examples

CopyC#
using System;
using DidiSoft.Pgp;

public class ImportPrivateKey
{
   public static void Demo()
   {
       KeyStore keyStore = new KeyStore(@"DataFiles\key.store", "changeit");
       KeyPairInformation key = keyStore.ImportPrivateKey(@"private_key.asc");            
   }
}
CopyVB.NET
Imports System
Imports DidiSoft.Pgp

Public Class ImportPrivateKey
   Public Shared Sub Demo()
       Dim keyStore As New KeyStore("DataFiles\key.store", "changeit")
       Dim key As KeyPairInformation = keyStore.ImportPrivateKey("private_key.asc")
   End Sub
End Class

Exceptions

ExceptionCondition
DidiSoft.Pgp.Exceptions..::..WrongPrivateKeyExceptionif there is no OpenPGP private key in the file
System.IO..::..IOExceptionI/O error

See Also