// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Security.Cryptography; using ICSharpCode.SharpZipLib.Checksums; namespace E { public class Program { private const int L = 10000; private const int REP = 250000; public static void Main(string[] args) { Random rng = new Random(); byte[] b = new byte[L]; rng.NextBytes(b); DateTime dt1 = DateTime.Now; for(int i = 0; i < REP; i++) { MD5 md5 = new MD5CryptoServiceProvider(); byte[] v = md5.ComputeHash(b); } DateTime dt2 = DateTime.Now; Console.WriteLine("MD5: " + (dt2 - dt1).TotalSeconds); DateTime dt3 = DateTime.Now; for(int i = 0; i < REP; i++) { Crc32 crc = new Crc32(); crc.Update(b); long v = crc.Value; } DateTime dt4 = DateTime.Now; Console.WriteLine("CRC-32: " + (dt4 - dt3).TotalSeconds); } } }