private void Btn_Decrypt_Click(object sender, EventArgs e) { if (Rdb_RsaEncrypt.Checked) { Txt_PlainText.Text = decrypt1(Txt_CipherText.Text, Txt_PrivateKey.Text); } else if (Rdb_AesECBEncrypt.Checked) { try { AESCryptography Aes = new AESCryptography(); var Dec = Aes.DecryptAsync(Txt_PublicKey.Text, Txt_CipherText.Text); Txt_PlainText.Text = Dec; } catch (Exception ex) { MessageBox.Show(ex.GetErrorMessage()); } } else if (Rdb_AesCBCEncrypt.Checked) { try { AESCBCModeCryptography Aes = new AESCBCModeCryptography(); var Dec = Aes.Decrypt(Txt_PublicKey.Text, Txt_CipherText.Text); Txt_PlainText.Text = Dec; } catch (Exception ex) { MessageBox.Show(ex.GetErrorMessage()); } } }
private string GenerateAesKey(bool isEcb) { if (isEcb) { AESCryptography aESCryptography = new AESCryptography(); return(aESCryptography.GenerateKey()); } else { AESCBCModeCryptography aESCBCMode = new AESCBCModeCryptography(); return(aESCBCMode.GenerateKey()); } }