我正在尝试创建一个rsa加密应用程序,这是我在C#中的代码:
class MainClass
{
public static RSAParameters parametros;
public static RSACryptoServiceProvider RSA;
static void Main()
{
UnicodeEncoding ByteConverter = new UnicodeEncoding();
byte[] dataToEncrypt = ByteConverter.GetBytes("hola mundo");
byte[] encryptedData;
parametros = new RSAParameters();
parametros.Modulus = new byte[] {
0xe5, 0x25, 0xea, 0x90, 0xdd, 0x50, 0xf8, 0x1f, 0xa7, 0x8f, 0x60,
0x4d, 0x21, 0x06, 0xc9, 0x15,
0x65, 0x0d, 0x21, 0x15, 0x8f, 0x98, 0x22, 0x2c, 0x6b, 0x41, 0x83,
0xed, 0x20, 0xfe, 0x77, 0x43,
0xd7, 0xf5, 0x5b, 0xc1, 0x97, 0x44, 0xeb, 0x61, 0xd6, 0xf7, 0x7f,
0xe7, 0xe4, 0xed, 0xf1, 0xda,
0xa0, 0x74, 0x33, 0xfd, 0x62, 0x67, 0x15, 0x9f, 0x02, 0xd0, 0xcc,
0xfa, 0xea, 0x8b, 0x31, 0x3c,
0x11, 0x03, 0xdc, 0x7d, 0xe2, 0x0b, 0x0f, 0xaa, 0x02, 0xfd, 0xb6,
0x90, 0xe9, 0x98, 0x15, 0xb5,
0xd5, 0xb7, 0x58, 0x24, 0xf9, 0x67, 0x06, 0xcc, 0x03, 0xad, 0xe1,
0x4e, 0xc3, 0xbf, 0x01, 0x2e,
0x7d, 0xc0, 0xed, 0x31, 0xd9, 0xa0, 0xaf, 0xc9, 0x8b, 0x8f, 0x53,
0x56, 0xd0, 0xcb, 0xcb, 0xc2,
0xf4, 0x5f, 0xcd, 0x3a, 0x4f, 0x6a, 0x28, 0x4d, 0x60, 0x3d, 0xcb,
0x8e, 0x5b, 0xad, 0xe4, 0xf3
};
parametros.Exponent = new byte[] { 0x01, 0x00, 0x01 };//{1,0,1};
RSA = new RSACryptoServiceProvider (1024);
RSA.ImportParameters (parametros);
for (int ii = 0; ii < 5; ii++) {
encryptedData = RSA.Encrypt(dataToEncrypt, false);
}
}
}
但是当我执行它时,它会返回具有相同键和指数的不同加密。
我认为这是因为淘汰,但我不知道如何防止这种情况。
请帮帮我吗?
非常感谢!