Exports private key from this OpenPGP key store as a byte array

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

Syntax

C#
public virtual byte[] ExportPrivateKeyBytes(
	string userId
)
Visual Basic
Public Overridable Function ExportPrivateKeyBytes ( _
	userId As String _
) As Byte()
Visual C++
public:
virtual array<unsigned char>^ ExportPrivateKeyBytes(
	String^ userId
)

Parameters

userId
Type: System..::..String
User Id of the form "name (comment) <email address>"

Return Value

requested Private key as byte array

Examples

CopyC#
using System;
using DidiSoft.Pgp;

public class ExportKeyBytes
{
   public void Demo()
   {
       KeyStore ks = new KeyStore(@"C:\Test\key.store", "changeit");
       byte[] keyBytes = ks.ExportPrivateKeyBytes("support@didisoft.com");
   }
}
CopyVB.NET
Imports System
Imports DidiSoft.Pgp

Public Class ExportKeyBytes
   Public Sub Demo()
       Dim ks As New KeyStore("C:\Test\key.store", "changeit")
       Dim keyAscii As Byte() = ks.ExportPrivateKeyBytes("support@didisoft.com")
   End Sub
End Class

Exceptions

ExceptionCondition
DidiSoft.Pgp.Exceptions..::..WrongPrivateKeyExceptionIf there is no private key in this key pair
System.IO..::..IOExceptionif an I/O error occurs.

See Also