示例#1
0
        private void tryXOREncryptDecrypt(Operation op)
        {
            string textToEncrypt = textBox1.Text;

            if (CaesarCipher.CheckInput(textToEncrypt, out MatchCollection matches))
            {
                textBox1.BackColor = Color.White;
                CaesarPswForm showPsw = new CaesarPswForm();
                if (DialogResult.Cancel == showPsw.ShowDialog(this))
                {
                    return;
                }
                textBox1.Text = xorEncryptionCipher.XOR(matches[0].Value,
                                                        Int32.Parse(showPsw.key), op);
            }
            else
            {
                textBox1.BackColor = Color.LightGoldenrodYellow;
                MessageBox.Show("Text contain illegal character!", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                textBox1.BackColor = Color.White;
            }
        }
示例#2
0
        private void tryThrithemiusEncryptDecrypt(Operation op)
        {
            string textToEncrypt = textBox1.Text;

            if (CaesarCipher.CheckInput(textToEncrypt, out MatchCollection matches))
            {
                textBox1.BackColor = Color.White;
                TrithemiusPswForm showPsw = new TrithemiusPswForm();
                do
                {
                    if (DialogResult.Cancel == showPsw.ShowDialog(this))
                    {
                        return;
                    }
                } while(showPsw.retry);
                textBox1.Text = trithemiusCipher.Trithemius(matches[0].Value, op, showPsw.TrithemiusKeyArgs);
            }
            else
            {
                textBox1.BackColor = Color.LightGoldenrodYellow;
                MessageBox.Show("Text contain illegal character!", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                textBox1.BackColor = Color.White;
            }
        }