public FormClient() { InitializeComponent(); aes = new Aes_256(); mySHA256 = SHA256Managed.Create(); Control.CheckForIllegalCrossThreadCalls = false; }
public void encryptmess(string mess) { if (mess.Length > 0) { md5 = new MD5(); aes = new Aes_256(); mySHA256 = SHA256Managed.Create(); byte[] mess1 = Encoding.UTF8.GetBytes(mess); byte[] key1 = mySHA256.ComputeHash(Encoding.ASCII.GetBytes(Convert.ToString(dh.Key_Chung))); textBoxkey.Text = Convert.ToBase64String(key1); string ivc = getdatime(); byte[] iv = create_init_vector(ivc, 2); textBoxiv.Text = Convert.ToBase64String(iv); byte[] dayhash = mySHA256.ComputeHash(Encoding.ASCII.GetBytes(ivc)); string encrypt = aes.EncryptString(mess1, key1, iv, dayhash); string[] enc1 = encrypt.Split(';'); string mess_md5 = md5.GetMD5(enc1[0] + Convert.ToString(dh.Key_Chung)); string messsend = "3;" + encrypt + ";" + ivc + ";" + mess_md5; textBoxmessnoise.Text = messsend; senddata(messsend); } }