Compare PublicKey object in java
问题 I have two PublicKey object.I want to compare both for equality or to check which is latest object using java security API or bouncy castle API.How can i achieve this? 回答1: You can use equals if (!key.equals(copyKey)){ System.out.println("not equals!"); } or check the hashcode of the keys if (key.hashCode() != copyKey.hashCode()) { System.out.println("public key hashCode check failed"); } or compare the hex string of the two public keys String encodedKey1 = new String(Hex.encode(key1