I do RSA encryption and I have to split my long string into small bytes [] and encrypt them. Then I combine the arrays and convert to a string and write to a protected file.
Encryption then creates a byte [128]
I use this to combine:
public static byte[] Combine(params byte[][] arrays)
{
byte[] ret = new byte[arrays.Sum(x => x.Length)];
int offset = 0;
foreach (byte[] data in arrays)
{
Buffer.BlockCopy(data, 0, ret, offset, data.Length);
offset += data.Length;
}
return ret;
}
When I decrypt, I take a string, convert it to a byte [] array, and now I need to split it to decode the pieces, and then convert it to a string.
Any ideas?
thanks
EDIT:
I think that now a split works for me, but decryption fails. Is it because of RSA keys, etc.? In TimePointA, he encrypts it, then in TimePointB he tries to decrypt it and it fails. Public keys are different, so they are not sure if this is a problem.