示例#1
0
        private void btnDecrypt_Click_1(object sender, EventArgs e)
        {
            if (richTextBox1.Text == string.Empty)
            {
                MessageBox.Show("Please give a valid textfile.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                stopwatch.Start();
                Decryption decryption = new Decryption();
                string     encryptedmessage;
                encryptedmessage   = decryption.GetBinary(richTextBox1.Text);
                richTextBox2.Lines = decryption.DecryptedMessage(encryptedmessage);
                message            = richTextBox2.Text;
                string SetenceString = message;
                var    result        = string.Join(" ", SetenceString.Split(' ').Distinct());
                richTextBox2.Text = result;
                stopwatch.Stop();
                int            duration = Convert.ToInt32(stopwatch.ElapsedMilliseconds);
                Communications com      = new Communications();
                Form1          form1    = new Form1();
                int            id       = form1.GetUserID();

                if (richTextBox2.Text == string.Empty)
                {
                    MessageBox.Show("Please give a valid textfile.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    com.AddCommunication(id, duration, message);
                }
            }
        }