private void button1_Click(object sender, EventArgs e) { MACHandler mh = new MACHandler(comboBoxMAC.Text); byte[] mac = mh.ComputeMAC(myConverter.StringToByteArray(textBoxPlain. Text), myConverter.StringToByteArray(textBoxKey.Text)); textBoxMAC.Text = myConverter.ByteArrayToString(mac); textBoxMACHEX.Text = myConverter.ByteArrayToHexString(mac); }
private void button2_Click(object sender, EventArgs e) { MACHandler mh = new MACHandler(comboBoxMAC.Text); if (mh.CheckAuthenticity(myConverter.StringToByteArray(textBoxPlain.Text), myConverter.HexStringToByteArray(textBoxMACHEX.Text), myConverter.StringToByteArray(textBoxKey.Text)) == true) { System.Windows.Forms.MessageBox.Show("MAC OK !!!"); } else { System.Windows.Forms.MessageBox.Show("MAC NOT OK !!!"); } }
private void button3_Click(object sender, EventArgs e) { MACHandler smth = new MACHandler(comboBoxMAC.Text); MemoryStream ms = new MemoryStream(); CryptoStream cs = new CryptoStream(ms, smth.myMAC, CryptoStreamMode.Write); byte[] mes_block = new byte[8]; long start_time = DateTime.Now.Ticks; int count = 10000000; for (int i = 0; i < count; i++) { cs.Write(mes_block, 0, mes_block.Length); } cs.Close(); double operation_time = (DateTime.Now.Ticks - start_time); operation_time = operation_time / (10 * count); labelEncTime.Text = "Time for encryption of a message block: " + operation_time.ToString() + " us"; }