コード例 #1
0
        public void btnEncryptFile_Click(object sender, EventArgs e)
        {
            if (txtFilePath.Text == "")
            {
                MessageBox.Show("Please Choose a File to Encrypt", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Error);
                btnBrowse.Focus();
            }
            else if (txtEnKey.Text == "")
            {
                MessageBox.Show("Enter Key for Encryption", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtEnKey.Focus();
            }
            else
            {
                pgsEncryptionBar.Show();

                Thread.Sleep(500);

                pgsEncryptionBar.Value = 20;
                Thread.Sleep(500);

                String inputString = rtbFileContent.Text;
                String key         = txtEnKey.Text;

                VigenereCipher vc = new VigenereCipher();

                EncryptedText = vc.EncryptText(inputString, key);

                pgsEncryptionBar.Value = 60;

                Thread.Sleep(500);

                pgsEncryptionBar.Value = pgsEncryptionBar.Maximum;
                lblDone.Show();

                Thread.Sleep(1500);

                btnViewFile.Show();
                btnClearAll.Show();
            }
        }
コード例 #2
0
        private void btnDecryptText_Click(object sender, EventArgs e)
        {
            if (rtbInputText.Text == "")
            {
                MessageBox.Show("Please Enter the text to Decrypt", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
            else if (txtKey.Text == "")
            {
                MessageBox.Show("Please Enter Decryption Key", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
            else
            {
                String inputString = rtbInputText.Text;
                String key         = txtKey.Text;

                VigenereCipher vc = new VigenereCipher();

                String DecryptedText = vc.DecryptText(inputString, key);

                rtbDecryptedText.Text = DecryptedText;
            }
        }