Ejemplo n.º 1
0
        private void btnDecTxt_Click(object sender, EventArgs e)
        {
            toolStripStatusLabel1.Text = "正在解密...";
            string rText = txtText.Text;

            if (checkBase64.Checked)
            {
                try
                {
                    byte[] rTextB64 = Convert.FromBase64String(rText);
                    rText = Encoding.Default.GetString(rTextB64);
                }
                catch (Exception err)
                {
                    toolStripStatusLabel1.Text = err.Message;
                    MessageBox.Show(toolStripStatusLabel1.Text, "操作失败", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            if (radioKeyMode1.Checked)
            {
                rText = Enc.decryptionAESData(tempAESKeyFile, rText);
            }
            else
            {
                rText = Enc.decryptionData(tempPrivateKeyFile, rText);
            }
            if (rText.Length == 0 && Enc.isErrorInfo())
            {
                toolStripStatusLabel1.Text = "解密操作失败";
                MessageBox.Show(Enc.getErrorOnce(), "解密操作失败", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                toolStripStatusLabel1.Text = "解密完成";
                txtText.Text = rText;
                tabControl1.SelectedIndex = 3;
            }
        }
Ejemplo n.º 2
0
        private void btnDecFile_Click(object sender, EventArgs e)
        {
            toolStripStatusLabel1.Text = "正在解密...";
            string rText = "";

            if (radioKeyMode1.Checked)
            {
                rText = Enc.decryptionAESData(tempAESKeyFile, txtFrom.Text, true, "aes-256-cbc", txtTo.Text);
            }
            else
            {
                rText = Enc.decryptionData(tempPrivateKeyFile, txtFrom.Text, true, txtTo.Text);
            }
            if (rText.Length == 0 && Enc.isErrorInfo())
            {
                toolStripStatusLabel1.Text = "解密操作失败";
                MessageBox.Show(Enc.getErrorOnce(), "解密操作失败", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                toolStripStatusLabel1.Text = "解密完成";
            }
        }