using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
byte[] PublicKey = {0x91,0xC7,0x3E,0xF8,0xBC,0x5E,0x99,0x28,0xF2,0x3C,0x5B,0x3B,0x2B,0x5B,0x59,0x0D,0x1F,0xB7,0x01,0xC5,0x3E,0xA1,0xCE,0x3B,0xC1,
0x2C,0xC8,0xB6,0x25,0xC0,0x60,0xC2,0x1A,0xE3,0x30,0x94,0x84,0x25,0x04,0xFF,0xD9,0xED,0x0E,0xFE,0xAE,0x85,0x44,0x49,0x0E,0xAB,
0xDA,0x1C,0x86,0xEC,0xF0,0xD6,0x0E,0xDB,0xF4,0x96,0x57,0xE3,0x15,0xA7,0xDC,0xEA,0x6F,0x5D,0x34,0x37,0x88,0x9B,0xF0,0xCE,0x77,
0xE5,0xF3,0x0A,0x4E,0x11,0x9C,0xED,0x37,0x3C,0xD4,0x4E,0xFC,0xB6,0x5A,0x8E,0xB4,0x06,0x29,0x04,0xF8,0x84,0x7D,0xA0,0x57,0x4F,
0x86,0x3F,0x2C,0x40,0x6C,0xFA,0x50,0x67,0x65,0xBA,0x31,0x23 };
byte[] Exponent = { 1, 0, 1 };
byte[] encrypted = {0x3D,0x7E,0x2F,0x95,0x21,0x73,0x75,0x28,0x4A,0x37,0x5C,0xAB,0x82,0x2B,0xAD,0x6A,0xCD,0x2E,0x60,0x96,0x61,0xEB,0x41,0xD6,0x6D,
0x3F,0x6E,0x5C,0x2F,0x51,0x20,0x6B,0x58,0x9B,0x40,0xD9,0x06,0x90,0xA8,0x6C,0xD7,0xE6,0x08,0x10,0x2D,0x6F,0x45,0x93,0x19,0x98,
0xC1,0xA0,0xB3,0x18,0x06,0xCD,0xDF,0xD2,0x09,0x6D,0x69,0x53,0x64,0x44,0xE1,0x87,0xC3,0xA3,0xB0,0xF0,0x50,0xDC,0x3B,0x1C,0x3B,
0x15,0x6A,0xC4,0x70,0x97,0x02,0x9E,0x27,0x7D,0x53,0x3B,0x39,0x1E,0xEB,0xF3,0xCC,0xEF,0x49,0xDF,0x1D,0x5D,0xBF,0x39,0x1D,0x95,
0x16,0xBB,0x5E,0x3E,0xEE,0x61,0x94,0x62,0xC4,0x04,0xDD,0xAA};
static byte[] Encrypt(byte[] input, RSAParameters RSAKeyInfo, bool DoOAEPPadding)
{
byte[] encrypted;
using (var RSA = new RSACryptoServiceProvider(896))
{
RSA.ImportParameters(RSAKeyInfo);
encrypted = RSA.Encrypt(input, DoOAEPPadding);
}
return encrypted;
}
RSACryptoServiceProvider RSA = new RSACryptoServiceProvider();
RSAParameters RSAKeyInfo = new RSAParameters();
RSAKeyInfo.Modulus = PublicKey;
RSAKeyInfo.Exponent = Exponent;
RSA.ImportParameters(RSAKeyInfo);
var pubKey = RSA.ExportParameters(false);
byte[] encrypted2 = Encrypt(encrypted, pubKey, false);
要加密的密钥和数据都具有相同的len 112字节,有帮助吗?