This example demonstrates how to delete a key pair from an OpenPGP KeyStore. We can delete only a public key, only a private key or a whole key pair (both public and private key).
import com.didisoft.pgp.KeyStore; public class DeleteKeyPair { public static void main(String[] args) throws Exception{ // initialize the KeyStore instance KeyStore ks = new KeyStore("pgp.keystore", "changeit"); // delete a public key ks.deletePublicKey("recipient@company.com"); // delete a private key ks.deletePrivateKey("mykey@mycompany.com"); // delete a key pair ks.deleteKeyPair("test@gmail.com"); } } |