GxHash.128bits.Overloads
1.2.1
dotnet add package GxHash.128bits.Overloads --version 1.2.1
NuGet\Install-Package GxHash.128bits.Overloads -Version 1.2.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="GxHash.128bits.Overloads" Version="1.2.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="GxHash.128bits.Overloads" Version="1.2.1" />
<PackageReference Include="GxHash.128bits.Overloads" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add GxHash.128bits.Overloads --version 1.2.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: GxHash.128bits.Overloads, 1.2.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=GxHash.128bits.Overloads&version=1.2.1
#tool nuget:?package=GxHash.128bits.Overloads&version=1.2.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
GxHash.128bits.Overloads
GxHash.128bits.Overloads is an extension library for GxHash that provides a comprehensive set of overloads to compute 128-bit hashes on various data types: files, string, ReadOnlySpan(T), Span(T), T[], List(T), Stream, T.
Features
- Compute 128-bit hash (
UInt128
) for:- File contents (
string filePath
) string
valuesSpan<byte>
andReadOnlySpan<byte>
- Generic
Span<T>
andReadOnlySpan<T>
whereT : unmanaged
- Arrays
T[]
whereT : unmanaged
- Lists
List<T>
whereT : unmanaged
Stream
instances
- File contents (
- Optional seeding for all methods
Installation
Install via NuGet:
Package | Download |
---|---|
GxHash.128bits.Overloads |
dotnet add package GxHash.128bits.Overloads
Quick Start
using GxHash.Overloads;
class Program
{
static void Main()
{
// Hash a string
UInt128 hash1 = GxHash128.Hash128("Hello, World!");
Console.WriteLine($"String hash: {hash1}");
// Hash with custom seed
UInt128 seed = new UInt128(1234567890, 9876543210);
UInt128 hash2 = GxHash128.Hash128("Hello, World!", seed);
Console.WriteLine($"String hash with seed: {hash2}");
// Hash a file
string path = "data.bin";
UInt128 fileHash = GxHash128.FileContentHash128(path);
Console.WriteLine($"File hash: {fileHash}");
// Hash a byte span
byte[] data = { 1, 2, 3, 4 };
UInt128 spanHash = GxHash128.Hash128((ReadOnlySpan<byte>)data);
Console.WriteLine($"Span hash: {spanHash}");
// Hash a stream
using var stream = File.OpenRead(path);
UInt128 streamHash = GxHash128.Hash128(stream, seed);
Console.WriteLine($"Stream hash: {streamHash}");
}
}
API Reference
namespace GxHash.Overloads;
public static class GxHash128
{
// File overloads
public static UInt128 FileContentHash128(string filePath);
public static UInt128 FileContentHash128(string filePath, UInt128 seed);
// String overloads
public static UInt128 Hash128(string? str);
public static UInt128 Hash128(string? str, UInt128 seed);
// Byte ReadOnlySpan overloads
public static UInt128 Hash128(ReadOnlySpan<byte> buffer);
public static UInt128 Hash128(ReadOnlySpan<byte> buffer, UInt128 seed);
public static UInt128 Hash128<T>(ReadOnlySpan<T> buffer) where T : unmanaged;
public static UInt128 Hash128<T>(ReadOnlySpan<T> buffer, UInt128 seed) where T : unmanaged;
// Byte Span overloads
public static UInt128 Hash128(Span<byte> buffer);
public static UInt128 Hash128(Span<byte> buffer, UInt128 seed);
public static UInt128 Hash128<T>(Span<T> buffer) where T : unmanaged;
public static UInt128 Hash128<T>(Span<T> buffer, UInt128 seed) where T : unmanaged;
// Array overloads
public static UInt128 Hash128<T>(T[]? array) where T : unmanaged;
public static UInt128 Hash128<T>(T[]? array, UInt128 seed) where T : unmanaged;
// List overloads
public static UInt128 Hash128<T>(List<T>? list) where T : unmanaged
public static UInt128 Hash128<T>(List<T>? list, UInt128 seed) where T : unmanaged
// Stream overload
public static UInt128 Hash128(Stream stream);
public static UInt128 Hash128(Stream stream, UInt128 seed);
// T overloads
public static unsafe UInt128 Hash128<T>(T value) where T : unmanaged
public static unsafe UInt128 Hash128<T>(T value, UInt128 seed) where T : unmanaged
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
1.2.0: Added overloads for T.
1.1.0: Added overloads for List.
1.0.0: First version