} //Doesn't need to change private void OpenEncryptedFileByteByte(object sender, RoutedEventArgs e) { string file = CrudFile.SetFileLocation(); byte[] data; try { data = GetBytes(CrudFile.CallOpenFileDialogS(file)); if (data != null) { dataContent.Text = BitConverter.ToString(data); } else if (fromBitConverterResult) { dataContent.Text = BitConverter.ToString(CrudFile.CallOpenFileDialogB(file)); } else { dataContent.Text = Encoding.ASCII.GetString(CrudFile.CallOpenFileDialogB(file)); } crypTypeStanMenuItem.IsChecked = true; } catch (ArgumentNullException) { return; } catch (FormatException) { MessageBox.Show("Incorrect input value!"); } } //Exist, Correct!
private void SaveConvertedFile(object sender, RoutedEventArgs e) { if (locationField.Text.Equals("")) { MessageBox.Show("Filelocation is empty!"); return; } if (passField.Password.Equals("")) { MessageBox.Show("Passfield is empty!"); return; } if (!encryptionRadio.IsChecked.GetValueOrDefault()) //Decryption { CrudFile.SaveDecryptedFile(File.ReadAllBytes(locationField.Text), passField.Password); } else //Encryption { if (passField.Password.Equals(passCheckField.Password)) { CrudFile.SaveEncryptedFile(File.ReadAllText(locationField.Text), passField.Password, true, false); } else { MessageBox.Show("Passwords are not same!"); } } CleanVariables(); }
} //Exist private void SaveDataToFile(object sender, RoutedEventArgs e) { if (dataContent.Text == "" || passField.Password == "") { MessageBox.Show("Text is empty!"); CleanPassWithContext(true); return; } if (!encStateBool) //Decr { if (!crypTypeStandardBool) // { CrudFile.SaveDecryptedFile(Convert.FromBase64String(dataContent.Text), passField.Password); } else if (crypTypeStandardBool && toBitConverterResult) { var data = GetBytes(dataContent.Text); if (data == null) { MessageBox.Show("Can't get bytes! Incorrect input data!"); CleanPassWithContext(false); return; } CrudFile.SaveDecryptedFile(data, passField.Password); data = null; } else if (crypTypeStandardBool && !toBitConverterResult) { MessageBox.Show("This mode doesn't work correct. Please, change it and try again!"); CleanPassWithContext(false); return; } else { MessageBox.Show("Something gone wrong..."); } } else //Encr { if (passField.Password.Equals(passCheckField.Password)) { CrudFile.SaveEncryptedFile(dataContent.Text, passField.Password, crypTypeStandardBool, toBitConverterResult); } else { MessageBox.Show("Passwords are not same!"); } } MessageBox.Show("Completed!"); dataContent.Text = ""; CleanPassWithContext(false); } //Exist, Need check
} //Exist, Correct! private void OpenDecryptedFile(object sender, RoutedEventArgs e) { string file = CrudFile.SetFileLocation(); try { dataContent.Text = CrudFile.CallOpenFileDialogS(file); } catch (ArgumentNullException) { return; } } //Exist
private void OpenFile(object sender, RoutedEventArgs e) { if (locationField.Text.Equals("")) { MessageBox.Show("You haven't chosen a file!"); return; } if (passField.Password.Equals("")) { MessageBox.Show("You haven't input a password!"); return; } CrudFile.OpenFile(locationField.Text, passField.Password); CleanVariables(); }
} //Exist private void SaveContextToFile(object sender, RoutedEventArgs e) { if (!toBitConverterResult) { CrudFile.CallSaveFileDialog(dataContent.Text); } else { byte[] data = GetBytes(dataContent.Text); if (data == null) { MessageBox.Show("Incorrect context! Can't save as hex data."); data = null; return; } CrudFile.CallSaveFileDialog(data); data = null; } MessageBox.Show("Successfully!"); } //Exist
} //Exist, Correct! private void OpenEncryptedFileBase64Base64(object sender, RoutedEventArgs e) { string file = CrudFile.SetFileLocation(); byte[] data; try { data = Convert.FromBase64String(CrudFile.CallOpenFileDialogS(file)); dataContent.Text = Convert.ToBase64String(data); crypTypeBase64MenuItem.IsChecked = true; } catch (ArgumentNullException) { return; } catch (FormatException) { MessageBox.Show("Incorrect input data!"); return; } } //Exist, Correct!
} //Exist, Correct! private void OpenEncryptedFileByteBase64(object sender, RoutedEventArgs e) { string file = CrudFile.SetFileLocation(); byte[] data; try { data = GetBytes(CrudFile.CallOpenFileDialogS(file)); if (data != null) { dataContent.Text = Convert.ToBase64String(data); } else { dataContent.Text = Convert.ToBase64String(CrudFile.CallOpenFileDialogB(file)); } crypTypeBase64MenuItem.IsChecked = true; } catch (ArgumentNullException) { return; } } //Exist, Correct!
private void CreateNewFile(object sender, RoutedEventArgs e) { CrudFile.CreateNewFile(encryptionRadio.IsChecked.GetValueOrDefault()); }
private void SetFileLocation(object sender, RoutedEventArgs e) { locationField.Text = CrudFile.SetFileLocation(); }