public void TestHash256() { const int minBitDelta = 64; // on average, the bit delta will be 128 var result0 = new byte[256 / 8]; var result1 = HashUtilities.ComputeHash256(new byte[0]); Console.WriteLine("Hashed to: {0}", StringUtilities.ToHexString(result1)); Assert.GreaterOrEqual(GetBitDelta(result0, result1), minBitDelta); var result1B = HashUtilities.ComputeHash256(new byte[0]); Console.WriteLine("Hashed to: {0}", StringUtilities.ToHexString(result1B)); Assert.AreEqual(GetBitDelta(result1, result1B), 0); var result2 = HashUtilities.ComputeHash256(Encoding.ASCII.GetBytes("ClearCanvas.Common.Utilities.Tests")); Console.WriteLine("Hashed to: {0}", StringUtilities.ToHexString(result2)); Assert.GreaterOrEqual(GetBitDelta(result0, result2), minBitDelta); Assert.GreaterOrEqual(GetBitDelta(result1, result2), minBitDelta); var result3 = HashUtilities.ComputeHash256(Encoding.ASCII.GetBytes("ClearCanvas.Commom.Utilities.Tests")); Console.WriteLine("Hashed to: {0}", StringUtilities.ToHexString(result3)); Assert.GreaterOrEqual(GetBitDelta(result0, result3), minBitDelta); Assert.GreaterOrEqual(GetBitDelta(result1, result3), minBitDelta); Assert.GreaterOrEqual(GetBitDelta(result2, result3), minBitDelta); var result4 = HashUtilities.ComputeHash256(Encoding.ASCII.GetBytes("ClearCanvas.Common.Utilities.Tests"), 18, 10); Console.WriteLine("Hashed to: {0}", StringUtilities.ToHexString(result4)); Assert.GreaterOrEqual(GetBitDelta(result0, result4), minBitDelta); Assert.GreaterOrEqual(GetBitDelta(result1, result4), minBitDelta); Assert.GreaterOrEqual(GetBitDelta(result2, result4), minBitDelta); Assert.GreaterOrEqual(GetBitDelta(result3, result4), minBitDelta); var result5 = HashUtilities.ComputeHash256(Encoding.ASCII.GetBytes("ClearCanvas.Commom.Utilities.Tests"), 18, 10); Console.WriteLine("Hashed to: {0}", StringUtilities.ToHexString(result5)); Assert.GreaterOrEqual(GetBitDelta(result0, result5), minBitDelta); Assert.GreaterOrEqual(GetBitDelta(result1, result5), minBitDelta); Assert.GreaterOrEqual(GetBitDelta(result2, result5), minBitDelta); Assert.GreaterOrEqual(GetBitDelta(result3, result5), minBitDelta); Assert.AreEqual(0, GetBitDelta(result4, result5), minBitDelta); }