コード例 #1
0
ファイル: MainForm.cs プロジェクト: iarovyi/e-crypt
        private void privateKeyField_TextChanged(object sender, EventArgs e)
        {
            string privateKey = File.ReadLines(privateKeyPathField.Text).First();

            if (!PGPValidator.IsPrivateKey(privateKey))
            {
                privateKeyValidityLabel.Text = "Provided private key is invalid";
                decrypt.Enabled = false;
            }
            else
            {
                privateKeyValidityLabel.Text = string.Empty;
                decrypt.Enabled = true;
            }
        }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: iarovyi/e-crypt
        private async void decrypt_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(destinationField.Text))
            {
                return;
            }

            string privateKey = File.ReadAllText(privateKeyPathField.Text);

            if (!PGPValidator.IsPrivateKey(privateKey))
            {
                MessageBox.Show("Provided private key is invalid", "", MessageBoxButtons.OK,
                                MessageBoxIcon.Warning);

                return;
            }

            DialogResult result;

            try
            {
                progressBar.Visible = true;
                DisableAllInputs();
                await appService.ExtractAsync(privateKey, destinationField.Text);

                progressBar.Visible      = false;
                lblSuccess.Visible       = true;
                selectPrivateKey.Enabled = false;
                openDestination.Visible  = true;

                MessageBox.Show(String.Format("The package is decrypted to {0}", destinationField.Text), "", MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                Logger.Error("Failed decrypt package: " + ex);
                result = MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error);

                if (result == DialogResult.OK)
                {
                    Close();
                }
            }
        }
コード例 #3
0
 public static void BeValidPublicKeyFilePath(this StringAssertions assertions)
 {
     BeExistingFilePath(assertions);
     ReadAllText(assertions.Subject).Should().Match(text => PGPValidator.IsPublicKey(text));
 }