51,410
社区成员
发帖
与我相关
我的任务
分享static const unsigned char EncPubKey[128] =
{
0xB2,0xC3,0x5E,0x20,0xCB,0x7C,0x8F,0xEE,0xAC,0xDD,0x46,0x5B,0x53,0x58,0x52,0x60,
0x87,0xBD,0x32,0xB2,0xAD,0x19,0x8B,0xD1,0x36,0x8F,0x76,0xB2,0x6B,0x42,0x84,0x9B,
0x87,0x35,0x5C,0x2B,0x2B,0x4A,0x76,0x0F,0x67,0x57,0x1E,0xC9,0x9E,0xE2,0x55,0x57,
0x84,0x9C,0xCB,0xDB,0xE6,0xA7,0x21,0x2F,0xCF,0xCA,0x18,0xF0,0x00,0xAC,0x03,0xAD,
0x70,0x9E,0xCC,0xC0,0xFF,0x5D,0x45,0xEF,0x5F,0xD4,0x22,0x5F,0xE7,0x03,0x99,0x0D,
0xEB,0x22,0x61,0x45,0x2B,0xDA,0x1F,0xD1,0x34,0x69,0xC0,0x21,0xC8,0xBA,0xD4,0x68,
0x36,0x8A,0xE9,0x17,0xF1,0x71,0x9C,0x14,0x9F,0xFF,0x68,0x4C,0x4A,0xDF,0x09,0x9C,
0xC1,0x6C,0x94,0x8A,0x59,0xD8,0xE5,0x72,0xD4,0x72,0xB5,0xB5,0x3A,0x85,0x75,0xBB,
};
rsa = RSA_new();
rsa->n = BN_bin2bn(EncPubKey, 128, rsa->n);
rsa->e = BN_bin2bn((unsignedchar*)"\x00\x01\x00\x01", 4, rsa->e);
rv = RSA_public_encrypt(128, rsa_key, dkey, rsa, RSA_NO_PADDING);
public static PublicKey getPublicKey(String modulusStr, String exponentStr) throws Exception{
BigInteger modulus=new BigInteger(modulusStr);
BigInteger exponent=new BigInteger(exponentStr);
RSAPublicKeySpec publicKeySpec=new RSAPublicKeySpec(modulus, exponent);
KeyFactory keyFactory=KeyFactory.getInstance("RSA");
return keyFactory.generatePublic(publicKeySpec);
}