大家好我得到的公钥如下
OpenSSLRSAPublicKey {模量= e6f4b594e1757261a98abe478f47b941cf8339933accc57d73d18bb8da906cf628da1949fb71c51f1635d93067ca2993599965f42d26237f63c1bc333de779051c36805f00ab5698a78e5616a7a7b0df487ba0fb3a89592780984562b96387443774331358a5920815bba2e24ad6c6c4ba6c7f52384847b4feea20190acdef000f6ee078352c0e0764e51dab25037d3d9c819a9be9ea240260ca2217ea4b446caf05d14318941a844ee82f567382c9fad8b959481c27785cdf6cb22ecf80f51bddc9f1c918d56b9bdd80ba4e766209069d0cf2012c0f15dbe4a8b5c2588a0ce295c2e90d44a52190289ab2fdceb22feffdadf623cab33e6a2e98be662cd5fecb,publicExponent = 10001}
使用下面的代码
KeyPairGenerator kpg;
KeyPair kp;
PublicKey publicKey;
kpg = KeyPairGenerator.getInstance("RSA");
kpg.initialize(2048);
kp = kpg.genKeyPair();
publicKey = kp.getPublic();
现在我想从中得到模数和 publicExponent 。
任何人都可以建议吗......?
答案 0 :(得分:1)
您必须将PublicKey
转换为RSAPublicKey
,例如
RSAPublicKey rsaPub = (RSAPublicKey)(kp.getPublic());
BigInteger modulus = rsaPub.getModulus();
BigInteger publicExponent = rsaPub getPublicExponent()