/// <summary> /// обработка сообщения DELETE /// </summary> /// <param name="iU"></param> /// <param name="data"></param> private void DeleteFile(byte[] data) { string name = GetPasString(data, 7 * 2); if (Login != Access.GetUser(name)) { Console.WriteLine("{0}: Неудачная попытка удалить файл {1}", Login, name); ConLog.WriteLine("{0}: Неудачная попытка удалить {1}", Login, name); SendResponse(CryWr, "ERROR"); return; } //////////////////////// byte[] Key = new byte[0x20]; byte[] IV = new byte[0x10]; for (int i = 0; i < 0x20; i++) { Key[i] = data[i + 7 * 2 + 1 + name.Length * 2]; } for (int i = 0; i < 0x10; i++) { IV[i] = data[i + 7 * 2 + 1 + name.Length * 2 + 0x20]; } byte[] DataFile = new byte[2 * 1048576]; //bool DecryptOk = false; //////////////////////////// разархивирование try { using (MemoryStream msResult = new MemoryStream()) { using (RijndaelManaged rijAlg = new RijndaelManaged()) { rijAlg.Key = Key; rijAlg.IV = IV; ICryptoTransform decryptor = rijAlg.CreateDecryptor(rijAlg.Key, rijAlg.IV); ZipStorer zip = ZipStorer.Open(name + ".zip", FileAccess.Read); List <ZipStorer.ZipFileEntry> dir = zip.ReadCentralDir(); Stream zs = zip.ExtractStream(dir[0]); using (CryptoStream csDecrypt = new CryptoStream(zs, decryptor, CryptoStreamMode.Read)) { //int iRead; zip.ExtractReadInNull(dir[0], csDecrypt, 0, (int)dir[0].FileSize); /*do * { * msResult.Seek(0, SeekOrigin.Begin); * iRead = zip.ExtractRead(dir[0], csDecrypt, msResult, 0, 2 * 1048576); * } while (iRead == 1048576 * 2); */ } zs.Dispose(); zip.Dispose(); } msResult.Close(); } } catch (Exception) { Console.WriteLine("{0}: Неудачная попытка удалить файл {1}", Login, name); ConLog.WriteLine("{0}: Неудачная попытка удалить {1}", Login, name); SendResponse(CryWr, "ERROR"); return; } DataFile = null; //////////////////////// if (Access.DeleteFile(name)) { File.Delete(name + ".zip"); } else { Console.WriteLine("{0}: Неудачная попытка удалить файл {1}", Login, name); ConLog.WriteLine("{0}: Неудачная попытка удалить {1}", Login, name); SendResponse(CryWr, "ERROR"); return; } Console.WriteLine("{0}: удалён файл {1}", Login, name); ConLog.WriteLine("{0}: удалён файл {1}", Login, name); SendResponse(CryWr, "OK"); }