private void btnDecrypt_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "Private Keys (*.xml)|*.xml"; if (openFileDialog.ShowDialog() == DialogResult.OK) { Stream temp = openFileDialog.OpenFile(); String privateKeyXml = new StreamReader(temp).ReadToEnd(); byte[] decryptedData = EncryptionClass.DecryptText(tbMessage.Text, privateKeyXml); tbResult.Text = Encoding.ASCII.GetString(decryptedData); } }