예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
            }
        }
예제 #4
0
        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;
        }
예제 #5
0
        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);
            }
        }
예제 #6
0
        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;
        }