Contact Us Forum Customers Area

DidiSoft Ltd.

Delete key from a KeyStore

The example below demonstrates how to delete a key pair from a KeyStore. The first key pair counted by the internal order of the KeyStore is erased. If only one of the keys of the key pair exists, for example only the public or only the private key, then only they will be deleted.

C#

using System;
using DidiSoft;
 
public class DeleteKeyPair
{
 public static void Demo()
 {
   // initialize the key store
   KeyStore ks = new KeyStore(@"DataFiles\key.store", "changeit");
 
   // delete the first key pair with this user Id
   ks.DeleteKeyPair("demo2@support.com");
 }
}

VB.NET

Imports System
Imports DidiSoft
 
Public Class DeleteKeyPair
 Public Shared Sub Demo()
  ' initialize the key store
  Dim ks As New KeyStore("DataFiles\key.store", "changeit")
 
  ' delete the first key pair with this user Id
  ks.DeleteKeyPair("demo2@didisoft.com")
 End Sub
End Class

If there is more than one key with the same user Id then we can use the overloaded version of the DeleteKeyPair method that accepts Key Id