private bool Export() { if (!ConfirmPassword()) { return(false); } if (!ValidatePath()) { return(false); } if (!OverwriteFile()) { return(false); } ImportExportUtility utility = new ImportExportUtility(); utility.Export(this.key, txtDestination.Text, chkEnabled.Checked ? txtPassword1.Text : String.Empty); MessageBox.Show(SR.ExportSuccessful, SR.ExportSuccessfulTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); return(true); }
private byte[] ImportKeyFromFile(string destinationFileName, string password) { byte[] key = null; try { ImportExportUtility utility = new ImportExportUtility(); key = utility.Import(destinationFileName, password); } catch (CryptographicException) { MessageBox.Show(SR.ImportDecryptError, SR.ImportDialogErrorTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (FormatException) { MessageBox.Show(SR.ImportDecryptFormatError, SR.ImportDialogErrorTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } return(key); }
private void Import() { if (!ValidateArguments()) { return; } byte[] key = null; ImportExportUtility utility = new ImportExportUtility(); try { bool keyFileIsPasswordProtected = utility.IsPasswordProtected(txtDestination.Text); if (keyFileIsPasswordProtected) { key = ImportPasswordProtectedKey(); } else { key = ImportKeyFromFile(txtDestination.Text, string.Empty); } if (key != null) { this.importedKey = key; MessageBox.Show(SR.ImportSuccessful, SR.ImportSuccessfulTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); this.DialogResult = DialogResult.OK; this.Close(); } } catch (FormatException) { MessageBox.Show(SR.ImportDecryptFormatError, SR.ImportDialogErrorTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private byte[] ImportKeyFromFile(string destinationFileName, string password) { byte[] key = null; try { ImportExportUtility utility = new ImportExportUtility(); key = utility.Import(destinationFileName, password); } catch (CryptographicException) { MessageBox.Show(SR.ImportDecryptError, SR.ImportDialogErrorTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } catch(FormatException) { MessageBox.Show(SR.ImportDecryptFormatError, SR.ImportDialogErrorTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } return key; }
private void Import() { if (!ValidateArguments()) { return; } byte[] key = null; ImportExportUtility utility = new ImportExportUtility(); try { bool keyFileIsPasswordProtected = utility.IsPasswordProtected(txtDestination.Text); if (keyFileIsPasswordProtected) { key = ImportPasswordProtectedKey(); } else { key = ImportKeyFromFile(txtDestination.Text, string.Empty); } if (key != null) { this.importedKey = key; MessageBox.Show(SR.ImportSuccessful, SR.ImportSuccessfulTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); this.DialogResult = DialogResult.OK; this.Close(); } } catch (FormatException) { MessageBox.Show(SR.ImportDecryptFormatError, SR.ImportDialogErrorTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private bool Export() { if (!ConfirmPassword()) { return false; } if (!ValidatePath()) { return false; } if (!OverwriteFile()) { return false; } ImportExportUtility utility = new ImportExportUtility(); utility.Export(this.key, txtDestination.Text, chkEnabled.Checked ? txtPassword1.Text : String.Empty); MessageBox.Show(SR.ExportSuccessful, SR.ExportSuccessfulTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); return true; }