private void decryptBtn_Click(object sender, EventArgs e) { switch (typeCb.SelectedIndex) { case 0: if (keyTxb.Text != "") { plain = Columnar.Decrypt(cipher, keyTxb.Text); } break; case 1: if (keyTxb.Text != "") { plain = DoubleTransposition.Decrypt(cipher, keyTxb.Text); } break; case 2: if (keyTxb.Text != "") { plain = Myszkowski.Decrypt(cipher, keyTxb.Text); } break; default: break; } this.Close(); }
private void encryptBtn_Click(object sender, EventArgs e) { if (((!showKeyChbx.Checked && (keyTxb.Text != "" && reenterTxb.Text != "") && (keyTxb.Text == reenterTxb.Text)) || (showKeyChbx.Checked && keyTxb.Text != "")) && plainTextRtb.Text != "") { if (typeCb.SelectedIndex == 0) { cipherTextRtb.Text = Columnar.Encrypt(plainTextRtb.Text, keyTxb.Text, paddingCb.SelectedIndex == 0 ? true : false); logDisplayRtb.Text += "Cipher type: columnar cipher \n"; logDisplayRtb.Text += "padding: " + (paddingCb.SelectedIndex == 0 ? true : false) + "\n"; } else if (typeCb.SelectedIndex == 1) { cipherTextRtb.Text = DoubleTransposition.Encrypt(plainTextRtb.Text, keyTxb.Text, paddingCb.SelectedIndex == 0 ? true : false); logDisplayRtb.Text += "Cipher type: double cipher \n"; logDisplayRtb.Text += "padding: " + (paddingCb.SelectedIndex == 0 ? true : false) + "\n"; } else if (typeCb.SelectedIndex == 2) { cipherTextRtb.Text = Myszkowski.Encrypt(plainTextRtb.Text, keyTxb.Text, paddingCb.SelectedIndex == 0 ? true : false); logDisplayRtb.Text += "Cipher type: myszowski cipher \n"; logDisplayRtb.Text += "padding: " + (paddingCb.SelectedIndex == 0 ? true : false) + "\n"; } } else if ((!showKeyChbx.Checked && (keyTxb.Text == "" || reenterTxb.Text == "")) && plainTextRtb.Text != "") { if (keyTxb.Text == "") { toolTip.Show("enter a key first", this, keyTxb.Location.X, keyTxb.Location.Y, 2000); } else { toolTip.Show("reenter the key first", this, reenterTxb.Location.X, reenterTxb.Location.Y, 2000); } } else if (((!showKeyChbx.Checked && (keyTxb.Text != "" && reenterTxb.Text != "") && (keyTxb.Text == reenterTxb.Text)) || (showKeyChbx.Checked && keyTxb.Text != "")) && plainTextRtb.Text == "") { toolTip.Show("no plain text to encrpt!\n provide a text", this, plainTextRtb.Location.X, plainTextRtb.Location.Y, 2000); } else if ((!showKeyChbx.Checked && (keyTxb.Text != "" && reenterTxb.Text != "") && (keyTxb.Text != reenterTxb.Text))) { toolTip.Show("reentered key not the same\n check your key", this, reenterTxb.Location.X, reenterTxb.Location.Y, 2000); } else if (showKeyChbx.Checked && keyTxb.Text == "") { toolTip.Show("enter a key first", this, keyTxb.Location.X, keyTxb.Location.Y, 2000); } }