diff --git a/dotnet.Nyzo.CL.Tests/ByteBufferTests.cs b/dotnet.Nyzo.CL.Tests/ByteBufferTests.cs index 6fd4910..6a9cf02 100644 --- a/dotnet.Nyzo.CL.Tests/ByteBufferTests.cs +++ b/dotnet.Nyzo.CL.Tests/ByteBufferTests.cs @@ -71,6 +71,32 @@ public void ComparingByteBufferWith_DifferentByteBufferInstance_ShouldYieldCorre Assert.True(byteBufferDuo2.Equals(byteBufferDuo1)); } + [Fact] + public void GetHashCode_UsedAsSourceOfTruth_ShouldEnableComparison() { + // Large amount of bytes with a small difference + var array = new byte[int.MaxValue / 10]; + var array1 = new byte[int.MaxValue / 10]; + + for(int i=0; i Nyzo.CL.Tests - 1.1.0 + 1.3.0 Benjamin Van Renterghem construct0 xUnit test project for the Nyzo class library (Nyzo.CL). The version indicates which Nyzo.CL version it is paired to. diff --git a/dotnet.Nyzo.CL/ByteBuffer.cs b/dotnet.Nyzo.CL/ByteBuffer.cs index d5e6b37..4ad5441 100644 --- a/dotnet.Nyzo.CL/ByteBuffer.cs +++ b/dotnet.Nyzo.CL/ByteBuffer.cs @@ -84,7 +84,9 @@ public override bool Equals(object? obj) { } public override int GetHashCode() { - throw new NotSupportedException(); + byte[] doubleSha256 = NyzoUtil.ByteArrayAsDoubleSha256ByteArray(this.Buffer); + + return BitConverter.ToInt32(doubleSha256); } // Position diff --git a/dotnet.Nyzo.CL/Nyzo.CL.csproj b/dotnet.Nyzo.CL/Nyzo.CL.csproj index b60c291..f5570ba 100644 --- a/dotnet.Nyzo.CL/Nyzo.CL.csproj +++ b/dotnet.Nyzo.CL/Nyzo.CL.csproj @@ -2,7 +2,7 @@ Nyzo.CL - 1.2.1 + 1.3.0 Benjamin Van Renterghem construct0 Nyzo class library. @@ -21,9 +21,9 @@ - - - + + +