2016-03-21 61 views
-2

大家好,我得到的公鑰如下獲取模量和publicExponent從Java公鑰

OpenSSLRSAPublicKey {模= e6f4b594e1757261a98abe478f47b941cf8339933accc57d73d18bb8da906cf628da1949fb71c51f1635d93067ca2993599965f42d26237f63c1bc333de779051c36805f00ab5698a78e5616a7a7b0df487ba0fb3a89592780984562b96387443774331358a5920815bba2e24ad6c6c4ba6c7f52384847b4feea20190acdef000f6ee078352c0e0764e51dab25037d3d9c819a9be9ea240260ca2217ea4b446caf05d14318941a844ee82f567382c9fad8b959481c27785cdf6cb22ecf80f51bddc9f1c918d56b9bdd80ba4e766209069d0cf2012c0f15dbe4a8b5c2588a0ce295c2e90d44a52190289ab2fdceb22feffdadf623cab33e6a2e98be662cd5fecb,publicExponent = 10001}

使用波紋管代碼

KeyPairGenerator kpg; 
KeyPair kp; 
PublicKey publicKey; 
kpg = KeyPairGenerator.getInstance("RSA"); 
kpg.initialize(2048); 
kp = kpg.genKeyPair(); 
publicKey = kp.getPublic(); 

現在我想從這個獲得publicExponent

任何人都可以請求...?

+3

這裏沒有問題。 –

回答

0

您必須將PublicKey轉換爲RSAPublicKey,例如,

RSAPublicKey rsaPub = (RSAPublicKey)(kp.getPublic()); 
BigInteger modulus = rsaPub.getModulus(); 
BigInteger publicExponent = rsaPub getPublicExponent()