httpd.conf
[2]这是用于公钥和私钥生成的椭圆曲线加密的代码,但是当我执行此代码时,只显示公钥而不显示私钥,所以请帮帮我,让我知道,该怎么做做生成私钥!!
答案 0 :(得分:0)
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.spec.ECGenParameterSpec;
public class ECCKeyGeneration {
public static void main(String[] args) {
try {
KeyPairGenerator kpg;
kpg = KeyPairGenerator.getInstance("EC","SunEC");
ECGenParameterSpec ecsp;
ecsp = new ECGenParameterSpec("secp192r1");
kpg.initialize(ecsp);
KeyPair kp = kpg.genKeyPair();
PrivateKey privKey = kp.getPrivate();
PublicKey pubKey = kp.getPublic();
System.out.println(privKey.toString());
System.out.println(pubKey.toString());
} catch (Exception ex) {
System.out.println(ex);
}
}
}
我刚刚测试了上面的代码。
<强>输出强>
Sun EC私钥,192位私有值: 3248833611418544793834748156439256292267803494576663573112个
参数:secp192r1 [NIST P-192,X9.62 prime192v1] (1.2.840.10045.3.1.1) Sun EC公钥,192位 public x coord: 5122655651118956061783347731888893733494103991283417332818 public y coord:223043343028867724454216740788693823451155477884918709166
参数:secp192r1 [NIST P-192,X9.62 prime192v1] (1.2.840.10045.3.1.1)
你得到相同的输出吗?