public static byte[] Encrypt(string _in) { int c = ASCIIProvider.Code; ASCIIProvider.Code = 10; _in = ASCIIProvider.Encrypt(_in); ASCIIProvider.Code = c; byte[] _out = AESProvider.Encrypt(new UTF8Encoding().GetBytes(_in)); _out = TripleDESProvider.Encrypt(_out); return(_out); }
private void encryptButton_Click(System.Object sender, System.EventArgs e) { string result = ""; string result2 = ""; if (asciiRadioButton.Checked) { result = ASCIIProvider.Encrypt(TextBox1.Text); result2 = ASCIIProvider.Decrypt(result); } else if (rijndaelRadioButton.Checked) { System.Text.Encoding myEnc = null; myEnc = System.Text.Encoding.GetEncoding("Windows-1252"); byte[] t = myEnc.GetBytes(TextBox1.Text.ToCharArray()); //convert string to bytes //Dim input() As Byte = m_utf8.GetBytes(TextBox1.Text.ToCharArray()) byte[] R = RijndaelProvider.Encrypt(t); result = myEnc.GetString(R); result2 = myEnc.GetString(RijndaelProvider.Decrypt(R)); } else if (desRadioButton.Checked) { result = DESProvider.Encrypt(TextBox1.Text); result2 = DESProvider.Decrypt(result); } else if (tripleDesRadioButton.Checked) { result = TripleDESProvider.Encrypt(TextBox1.Text); result2 = TripleDESProvider.Decrypt(result); } else if (xorRadioButton.Checked) { result = XorProvider.Encrypt(TextBox1.Text); result2 = XorProvider.Decrypt(result); } else if (aesRadioButton.Checked) { result = AESProvider.Encrypt(TextBox1.Text); result2 = AESProvider.Decrypt(result); } else if (rcTwoRadioButton.Checked) { result = RC2Provider.Encrypt(TextBox1.Text); result2 = RC2Provider.Decrypt(result); } else if (rsaRadioButton.Checked) { try { result = RSAProvider.Encrypt(TextBox1.Text); result2 = RSAProvider.Decrypt(result); } catch (Exception ex) { Interaction.MsgBox(ex.ToString()); TextBox1.Text = ex.ToString(); } } else { Interaction.MsgBox("Invalid Option!!!"); return; } outputLabel.Text = "Encrypted Result: " + result + " Decrypted Result: " + result2; }