0
大家好我新來java ecc encryption.so我從ECC卡得到ECC公鑰數據數組,大小爲49字節length.so我需要gelcrate Eccpublic key.so我創建了公鑰。但它給java.security.spec.InvalidKeySpecException: encoded key spec not recognised
error.This是我的代碼任何人都可以幫助我如何使用數據array.Thanksjava中的Genarate ECPublicKey
byte[] pub = new byte[] {
/*(Public data) 49 length byte ARRAY
*/
};
System.out.println("Length :" + pub.length);
X509EncodedKeySpec ks = new X509EncodedKeySpec(pub);
KeyFactory kf;
try {
kf = KeyFactory.getInstance("ECDH");
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
return;
}
ECPublicKey remotePublicKey;
try {
remotePublicKey = (ECPublicKey) kf.generatePublic(ks);
} catch (InvalidKeySpecException e) {
e.printStackTrace();
return;
} catch (ClassCastException e) {
e.printStackTrace();
return;
}
System.out.println(remotePublicKey);
} catch (Exception e) {
e.printStackTrace();
}
您可以將實際數據添加到數據數組中嗎? – gtrig