using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Cryptography;
using System.IO;
namespace EncryptionTest
{
class Program
{
static void Main(string[] args)
{
UnicodeEncoding ByteConverter = new UnicodeEncoding();
byte[] dataToEncrypt = ByteConverter.GetBytes("Test data");
string enc = Encrypt(dataToEncrypt);
}
static string Encrypt(byte[] data)
{
UnicodeEncoding ByteConverter = new UnicodeEncoding();
RSACryptoServiceProvider encrypt = new RSACryptoServiceProvider();
byte[] encryptedData = encrypt.Encrypt(data, false); //Repeat this line
return ByteConverter.GetString(encryptedData);
}
}
}
I used 'Set Next Statement' to repeatedly execute the following statement, i.e without any other lines of code being executed.
byte[] encryptedData = encrypt.Encrypt(data, false);
I looked at the bytes in encryptedData and found that the bytes in encryptedData change each time. Surely this is wrong? If the public key hasn't changed and the data to be encrypted hasn't been changed then the 'encryptedData' bytes should not change either?