private void buttonDecrypt_Click(object sender, EventArgs e) { if (textBoxDecryptText.Text.Length == 0) { MessageBox.Show("Введите текст зашифрованного сообщения!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (privateKey == null) { MessageBox.Show("Выберете закрытый ключ!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (textBoxEDecryptPassphrase.Text.Length == 0) { MessageBox.Show("Введите парольную фразу!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } try { privateKey.DecryptByPassphrase(textBoxEDecryptPassphrase.Text); } catch (Exception) { MessageBox.Show("Неверная парольная фраза!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string decryption = privateKey.Decrypt(textBoxDecryptText.Text); textBoxDecryptMessage.Text = decryption; textBoxDecryptText.Text = ""; textBoxEDecryptPassphrase.Text = ""; labelDecryptPrivateKey.Text = ""; privateKey = null; }