diff --git a/src/Standart.Hash.xxHash/xxHash32.Array.cs b/src/Standart.Hash.xxHash/xxHash32.Array.cs index 64edd71..c0c8b5f 100644 --- a/src/Standart.Hash.xxHash/xxHash32.Array.cs +++ b/src/Standart.Hash.xxHash/xxHash32.Array.cs @@ -22,5 +22,39 @@ return UnsafeComputeHash(pData, length, seed); } } + + /// + /// Compute xxHash for the data byte array + /// + /// The source of data + /// The offset of the data for hashing + /// The length of the data for hashing + /// The seed number + /// hash + public static unsafe uint ComputeHash(byte[] data, int offset, int length, uint seed = 0) + { + Debug.Assert(data != null); + Debug.Assert(length >= 0); + Debug.Assert(offset < data.Length); + Debug.Assert(length <= data.Length - offset); + + fixed (byte* pData = &data[0 + offset]) + { + return UnsafeComputeHash(pData, length, seed); + } + } + /// + /// Compute xxHash for the data byte array + /// + /// The source of data + /// The seed number + /// hash + public static unsafe ulong ComputeHash(System.ArraySegment data, uint seed = 0) + { + Debug.Assert(data != null); + + return ComputeHash(data.Array, data.Offset, data.Count, seed); + } + } } \ No newline at end of file diff --git a/src/Standart.Hash.xxHash/xxHash64.Array.cs b/src/Standart.Hash.xxHash/xxHash64.Array.cs index 888913f..f7f3a11 100644 --- a/src/Standart.Hash.xxHash/xxHash64.Array.cs +++ b/src/Standart.Hash.xxHash/xxHash64.Array.cs @@ -22,5 +22,37 @@ return UnsafeComputeHash(pData, length, seed); } } + /// + /// Compute xxHash for the data byte array + /// + /// The source of data + /// The length of the data for hashing + /// The seed number + /// hash + public static unsafe ulong ComputeHash(byte[] data, int offset, int length, ulong seed = 0) + { + Debug.Assert(data != null); + Debug.Assert(length >= 0); + Debug.Assert(offset < data.Length); + Debug.Assert(length <= data.Length - offset); + + fixed (byte* pData = &data[0 + offset]) + { + return UnsafeComputeHash(pData, length, seed); + } + } + /// + /// Compute xxHash for the data byte array + /// + /// The source of data + /// The seed number + /// hash + public static unsafe ulong ComputeHash(System.ArraySegment data, ulong seed = 0) + { + Debug.Assert(data != null); + + return ComputeHash(data.Array, data.Offset, data.Count, seed); + } + } } \ No newline at end of file