private void dearchiveButton_Click(object sender, EventArgs e) { string filepath = filepathDearchTextBox.Text; string outputPath = outputDearchTextBox.Text; IntPtr passBstrPointer = Marshal.SecureStringToBSTR(passDearchTextBox.SecureString); IntPtr repBstrPointer = Marshal.SecureStringToBSTR(repDearchTextBox.SecureString); string password = SecureStringHandler.Encrypt(SecureStringHandler.ExtractStringFromSecureString(passBstrPointer)); string repPassword = SecureStringHandler.Encrypt(SecureStringHandler.ExtractStringFromSecureString(repBstrPointer)); if (password != repPassword) { MessageBox.Show("Hasła nie są identyczne", "Wiadomość"); } else if (filepath.Equals("") || outputPath.Equals("") || (passDearchTextBox.SecureString.Length == 0)) { MessageBox.Show("Nie wprowadzono wszystkich danych", "Wiadomość"); } else { List <string> passwordIngredients = new List <string>(); passwordIngredients.Add(password); passwordIngredients.Add(SecureStringHandler.FetchMotherboardID()); dearchiveState(false); CompressionEngine.DecryptAndExtract(filepath, outputPath, passwordIngredients); dearchiveState(true); } }
private void archiveButton_Click(object sender, EventArgs e) { List <string> filepaths = new List <string>(); foreach (DataGridViewRow row in filepathGridView.Rows) { filepaths.Add(row.Cells[0].Value.ToString().Trim()); } string outputPath = outputArchTextBox.Text; string name = nameTextBox.Text; CompressionEngine.CompressionType method = (CompressionEngine.CompressionType)methodComboBox.SelectedIndex; int level = Convert.ToInt32(levelNumericBox.Value); IntPtr passBstrPointer = Marshal.SecureStringToBSTR(passArchTextBox.SecureString); IntPtr repBstrPointer = Marshal.SecureStringToBSTR(repArchTextBox.SecureString); string password = SecureStringHandler.Encrypt(SecureStringHandler.ExtractStringFromSecureString(passBstrPointer)); string repPassword = SecureStringHandler.Encrypt(SecureStringHandler.ExtractStringFromSecureString(repBstrPointer)); if (password != repPassword) { MessageBox.Show("Hasła nie są identyczne", "Wiadomość"); } else if ((filepaths.Count() == 0) || outputPath.Equals("") || name.Equals("") || method.Equals("") || (passArchTextBox.SecureString.Length == 0)) { MessageBox.Show("Nie wprowadzono wszystkich danych", "Wiadomość"); } else { string fptest = ""; foreach (string path in filepaths) { fptest += "\n" + path; } List <string> passwordIngredients = new List <string>(); passwordIngredients.Add(password); passwordIngredients.Add(SecureStringHandler.FetchMotherboardID()); archiveState(false); CompressionEngine.CreateEncryptedArchive(outputPath, name, method, filepaths, passwordIngredients, level); archiveState(true); } }