-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Closed
Labels
api-approvedAPI was approved in API review, it can be implementedAPI was approved in API review, it can be implementedarea-System.IO.Hashing
Milestone
Description
Background and motivation
Followup of the previous API proposal for XX3 64 bit #75948
The current XxHash3 implementation provides a 64 bit hash. But XXH3 128 is also quite useful for e.g fast content adressable storage scenarios.
This proposal is about adding a XxHash128 API and implementation.
API Proposal
namespace System.IO.Hashing;
public sealed partial class XxHash128 : NonCryptographicHashAlgorithm
{
public XxHash128();
public XxHash128(long seed);
public static byte[] Hash(byte[] source);
public static byte[] Hash(byte[] source, long seed);
public static byte[] Hash(ReadOnlySpan<byte> source, long seed = 0);
public static int Hash(ReadOnlySpan<byte> source, Span<byte> destination, long seed = 0);
public static bool TryHash(ReadOnlySpan<byte> source, Span<byte> destination, out int bytesWritten, long seed = 0);
// .NET 7+
public static UInt128 HashToIntU128(ReadOnlySpan<byte> source, long seed = 0);
public UInt128 GetCurrentHashAsIntU128();
}API Usage
int bytesWritten = XxHash128.Hash(source, destination);Alternative Designs
No response
Risks
No response
filipnavara, MihaZupan and AlgorithmsAreCoolsamsosa
Metadata
Metadata
Assignees
Labels
api-approvedAPI was approved in API review, it can be implementedAPI was approved in API review, it can be implementedarea-System.IO.Hashing