public
static
bool
FileDecryptNew(
string
inputFile,
string
outputFile,
string
privateKey,
int
size)
{
bool
result =
true
;
byte
[] array =
new
byte
[0x80];
FileStream fileStream =
new
FileStream(inputFile, FileMode.Open);
fileStream.Read(array, 0, 0x80);
byte
[] src =
new
RSAUtil().DecryptByBytes(array, privateKey);
byte
[] array2 =
new
byte
[0x20];
byte
[] array3 =
new
byte
[0x10];
Buffer.BlockCopy(src, 0, array2, 0, array2.Length);
Buffer.BlockCopy(src, 0x20, array3, 0, array3.Length);
CryptoStream cryptoStream =
new
CryptoStream(fileStream,
new
RijndaelManaged
{
KeySize = 0x100,
BlockSize = 0x80,
Key = array2,
IV = array3,
Padding = PaddingMode.PKCS7,
Mode = CipherMode.CFB
}.CreateDecryptor(), CryptoStreamMode.Read);
FileStream fileStream2 =
new
FileStream(outputFile, FileMode.Create);
byte
[] array4 =
new
byte
[size];
try
{
int
count;
while
((count = cryptoStream.Read(array4, 0, array4.Length)) > 0)
{
fileStream2.Write(array4, 0, count);
}
}
catch
(CryptographicException ex)
{
result =
false
;
Console.WriteLine(
"CryptographicException error: "
+ ex.Message);
}
catch
(Exception ex2)
{
result =
false
;
Console.WriteLine(
"Error: "
+ ex2.Message);
}
try
{
cryptoStream.Close();
}
catch
(Exception ex3)
{
result =
false
;
Console.WriteLine(
"Error by closing CryptoStream: "
+ ex3.Message);
}
finally
{
fileStream2.Close();
fileStream.Close();
}
return
result;
}