// 根据n、e值还原公钥
public static PublicKey getPublicKey(String modulus, String publicExponent)
throws NoSuchAlgorithmException, InvalidKeySpecException {
BigInteger bigIntModulus = new BigInteger(modulus,16);
BigInteger bigIntPrivateExponent = new BigInteger(publicExponent,16);
RSAPublicKeySpec keySpec = new RSAPublicKeySpec(bigIntModulus, bigIntPrivateExponent);
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
PublicKey publicKey = keyFactory.generatePublic(keySpec);
return publicKey;
}
本文介绍了一种通过n和e值来生成RSA公钥的方法。该方法使用BigInteger类处理模数和指数,并通过RSAPublicKeySpec指定公钥参数。最后通过KeyFactory生成公钥。

4277

被折叠的 条评论
为什么被折叠?



