I have an application in C# that encrypt part of my files (because they are big files) using RijndaelManaged. So I convert my file to byte arrays and encrypt only a part of it.
Then I want to decrypt the file using Java. So I have to decrypt only part of the file (means those bytes) that was encrypted in C#.
Here the problem comes. Because in C# we have unsigned bytes and in Java we have signed bytes. So my encryption and decryption not working the way I want.
In C# I have joined the encrypted bytes and normal bytes together and saved them with File.WriteAllBytes
. So I can't use sbyte here or I don't know how to do it:
byte[] myEncryptedFile = new byte[myFile.Length];
for (long i = 0; i < encryptedBlockBytes.Length; i++)
{
myEncryptedFile[i] = encryptedBlockBytes[i];
}
for (long i = encryptedBlockBytes.Length; i < myFile.Length; i++)
{
myEncryptedFile[i] = myFileBytes[i];
}
File.WriteAllBytes(@"C:\enc_file.big", myEncryptedFile);
( And there is an exact same code for decryption in Java )
So my questions are:
- Is there any WriteAllsBytes in C#?
- Or can I use unsigned bytes in Java?
- Or any other solutions to my problem?