public static void Run(BigInteger secretPhrase) { //Have to use the same IV Random r = new Random(); byte[] iv = new byte[16]; r.NextBytes(iv); byte[] a = SimpleAES.GenerateEncryptionVector(); SimpleAES aes1 = new SimpleAES(secretPhrase.GetBytes(), iv); SimpleAES aes2 = new SimpleAES(secretPhrase.GetBytes(), iv); int numberOfRuns = 10000; Stopwatch timer = new Stopwatch(); timer.Start(); for (int i = 0; i < numberOfRuns; i++) { r.NextBytes(iv); aes1.SetIV(iv); //aes2.SetIV(iv); byte[] encrypted = aes1.Encrypt(randomPacket, randomPacket.Length); byte[] decrypted = aes2.Decrypt(encrypted, encrypted.Length); #if DEBUG for (int j = 0; j < randomPacket.Length; j++) { Debug.Assert(decrypted[j] == randomPacket[j]); } #endif } for (int i = 0; i < numberOfRuns; i++) { r.NextBytes(iv); aes1.SetIV(iv); //aes2.SetIV(iv); byte[] encrypted = aes2.Encrypt(randomPacket, randomPacket.Length); byte[] decrypted = aes1.Decrypt(encrypted, encrypted.Length); #if DEBUG for (int j = 0; j < randomPacket.Length; j++) { Debug.Assert(decrypted[j] == randomPacket[j]); } #endif } timer.Stop(); Console.WriteLine("AESProfiler took " + timer.ElapsedMilliseconds + " millseconds."); Console.WriteLine("or " + (double)timer.ElapsedMilliseconds / (double)(numberOfRuns + numberOfRuns) + " millseconds per encrypt + decrypt"); }