Returns the key pairs stored in this OpenPGP key store.

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

Syntax

C#
public virtual KeyPairInformation[] GetKeys()
Visual Basic
Public Overridable Function GetKeys As KeyPairInformation()
Visual C++
public:
virtual array<KeyPairInformation^>^ GetKeys()

Return Value

Array of KeyPairInformation objects stored in this instance of KeyStore. If there are no keys, returns empty array.

Examples

CopyC#
using System;
using System.Text;
using DidiSoft.Pgp;

public class KeyStoreListKeys
{
   public static void Demo()
   {
       KeyStore ks = new KeyStore(@"DataFiles\key.store", "changeit");
       KeyPairInformation[] keys = ks.GetKeys();

       foreach (KeyPairInformation key in keys) {
           Console.WriteLine(key.KeyId);
               foreach (String id in key.UserIds) {
                 Console.WriteLine(id);
               }
           }
   }
}
CopyVB.NET
Imports System
Imports System.Text
Imports DidiSoft.Pgp

Public Class KeyStoreListKeys
   Public Shared Sub Demo()
       Dim ks As New KeyStore("DataFiles\key.store", "changeit")
       Dim keys As KeyPairInformation() = ks.GetKeys()

       For Each key As KeyPairInformation In keys

           Console.WriteLine(key.KeyId)

           For Each id As String In key.UserIds
               Console.WriteLine(id)
           Next
       Next
   End Sub
End Class

See Also