private void menuXorKey_Click(object sender, EventArgs e) { XorDlg xor = new XorDlg(); xor.SetType(XorType.Encrypt, m_XorKey); if (xor.ShowDialog() == DialogResult.OK) { m_XorKey = xor.XorKey; } }
/////////////////////////////////////////////////////////////////////////////////////////////////// // // ZIP Handlers // /////////////////////////////////////////////////////////////////////////////////////////////////// public void LoadZipFile(string path, bool breakOnFail = false) { m_File = path; this.Text = String.Format(Strings.WindowNameLoaded, m_File, ""); m_Archive = new Archive(m_File, true, (EncryptionType)comboEncrypt.SelectedIndex); List <ArchiveEntry> entries = m_Archive.getEntries(); if (m_Archive == null || entries == null) { if (breakOnFail) { MessageBox.Show("The file is not a valid zip file or the Xor key is wrong!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); CloseCurrentFile(); return; } if (!KeyDatabase.SearchKey(Path.GetFileName(path), out m_XorKey) || MessageBox.Show(String.Format("The Key {0} was found for {1} in our database, would you like to use it?", m_XorKey, Path.GetFileName(path)) , "A key was found!" , MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) != DialogResult.Yes) { XorDlg xor = new XorDlg(); xor.SetType(XorType.Decrypt); if (xor.ShowDialog() != DialogResult.OK) { CloseCurrentFile(); return; } m_XorKey = xor.XorKey; } if (String.IsNullOrEmpty(m_XorKey)) { CloseCurrentFile(); return; } string decryptedPath = String.Format("{0}{1}", Path.GetTempPath(), Path.GetFileName(path)); if (File.Exists(decryptedPath)) { File.Delete(decryptedPath); } File.Copy(path, decryptedPath); // Decrypt here XorFile(decryptedPath, m_XorKey); LoadZipFile(decryptedPath, true); File.Delete(decryptedPath); return; } // Load associated icons foreach (ArchiveEntry entry in entries) { AddFile(entry.getNameExtension(), entry.getExtension(), entry.getSizeData(), entry.getId(), path + "\\" + entry.getName()); } SetLoadedState(true); }