话不多说,看代码吧....
package com.test;
import java.math.BigInteger;
import java.security.KeyFactory;
import java.security.PublicKey;
import java.security.interfaces.RSAPublicKey;
import java.security.spec.RSAPublicKeySpec;
import java.util.Base64;
public class RSA {
/** 算法 */
private static String ALGORITHM = "RSA";
/** RSA bits */
private static int KEYSIZE = 1024;
/** 由模和指数构造公钥对象,模和指数由16进制字符串表示 */
public static RSAPublicKey CreatePublicKeyFromModulus(String modulusIn16Radix, String exponentIn16Radix) throws Exception {
BigInteger m = new BigInteger(modulusIn16Radix, 16);
BigInteger e = new BigInteger(exponentIn16Radix, 16);
KeyFactory keyFactory = KeyFactory.getInstance(ALGORITHM);
RSAPublicKeySpec keySpec = new RSAPublicKeySpec(m, e);