Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
using System;
using System.Security.Cryptography;
using BenchmarkDotNet.Attributes;
namespace TestingBenchmarkDotNet
{
public class Md5VsSha256
{
private const int N = 10000;
private readonly byte[] data;
private readonly SHA256 sha256 = SHA256.Create();
private readonly MD5 md5 = MD5.Create()
public static void Main(string[] args)
{
Console.WriteLine("Hello World! - From a Benchmark!!");
}
public Md5VsSha256()
{
data = new byte[N];
new Random(42).NextBytes(data);
}
[Benchmark]
public byte[] Sha256()
{
return sha256.ComputeHash(data);
}
[Benchmark]
public byte[] Md5()
{
return md5.ComputeHash(data);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment