Pure.HashCodes
2.2.0
dotnet add package Pure.HashCodes --version 2.2.0
NuGet\Install-Package Pure.HashCodes -Version 2.2.0
<PackageReference Include="Pure.HashCodes" Version="2.2.0" />
<PackageVersion Include="Pure.HashCodes" Version="2.2.0" />
<PackageReference Include="Pure.HashCodes" />
paket add Pure.HashCodes --version 2.2.0
#r "nuget: Pure.HashCodes, 2.2.0"
#:package Pure.HashCodes@2.2.0
#addin nuget:?package=Pure.HashCodes&version=2.2.0
#tool nuget:?package=Pure.HashCodes&version=2.2.0
Pure.HashCodes
Deterministic hash code generation for the Pure ecosystem — stable, byte-enumerable hashes over immutable primitive types.
Overview
Pure.HashCodes provides a single entry point — DeterminedHash — that produces a stable, ordered sequence of bytes for any value implementing a Pure.Primitives.Abstractions interface. Unlike object.GetHashCode(), the output is deterministic across processes and runtimes and can be combined from multiple fields into a single compound hash.
GetHashCode() and ToString() are intentionally unsupported on DeterminedHash and throw NotSupportedException — callers must consume the byte sequence directly.
API
DeterminedHash is a sealed record implementing IDeterminedHash : IEnumerable<byte>.
Constructors
| Constructor | Input type |
|---|---|
DeterminedHash(IBool) |
Boolean value |
DeterminedHash(IChar) |
Single character |
DeterminedHash(IDate) |
Date (day / month / year) |
DeterminedHash(ITime) |
Time (hour / minute / second / …) |
DeterminedHash(IDateTime) |
Date + time composition |
DeterminedHash(IDayOfWeek) |
Day of week |
DeterminedHash(INumber<double>) |
64-bit floating point |
DeterminedHash(INumber<float>) |
32-bit floating point |
DeterminedHash(INumber<int>) |
Signed 32-bit integer |
DeterminedHash(INumber<uint>) |
Unsigned 32-bit integer |
DeterminedHash(INumber<ushort>) |
Unsigned 16-bit integer |
DeterminedHash(IGuid) |
GUID value |
DeterminedHash(IString) |
String value |
DeterminedHash(IEnumerable<IDeterminedHash>) |
Aggregated compound hash |
DeterminedHash(IEnumerable<byte>) |
Raw byte sequence |
Design Principles
- Deterministic — identical inputs always produce identical byte sequences, regardless of runtime or process lifetime.
- Abstraction-driven — works exclusively with
Pure.Primitives.Abstractionsinterfaces, not concrete types. - Composable — multiple
DeterminedHashvalues can be aggregated into a single compound hash viaIEnumerable<IDeterminedHash>. - AOT-compatible — the library is fully compatible with Native AOT compilation.
Dependencies
Pure.HashCodes.Abstractions— definesIDeterminedHash : IEnumerable<byte>, the core hash abstractionPure.Primitives.Abstractions— read-only interfaces for primitive types (IBool,IChar,IDate,ITime,IDateTime,IDayOfWeek,INumber<T>,IGuid,IString)
Target Frameworks
- .NET 7
- .NET 8
- .NET 9
- .NET 10
- .NET 11
Installation
dotnet add package Pure.HashCodes
Usage
Hash a single primitive:
using Pure.HashCodes;
using Pure.Primitives.Number;
INumber<int> id = new Int(42);
IEnumerable<byte> hashBytes = new DeterminedHash(id);
Combine multiple fields into a compound hash:
using Pure.HashCodes;
using Pure.HashCodes.Abstractions;
IDeterminedHash nameHash = new DeterminedHash(name);
IDeterminedHash dateHash = new DeterminedHash(birthDate);
IEnumerable<byte> compound = new DeterminedHash(new[] { nameHash, dateHash });
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. 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 is compatible. 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. net11.0 is compatible. |
-
net10.0
- Pure.HashCodes.Abstractions (>= 1.0.0)
- Pure.Primitives.Abstractions (>= 4.4.0)
-
net11.0
- Pure.HashCodes.Abstractions (>= 1.0.0)
- Pure.Primitives.Abstractions (>= 4.4.0)
-
net7.0
- Pure.HashCodes.Abstractions (>= 1.0.0)
- Pure.Primitives.Abstractions (>= 4.4.0)
-
net8.0
- Pure.HashCodes.Abstractions (>= 1.0.0)
- Pure.Primitives.Abstractions (>= 4.4.0)
-
net9.0
- Pure.HashCodes.Abstractions (>= 1.0.0)
- Pure.Primitives.Abstractions (>= 4.4.0)
NuGet packages (8)
Showing the top 5 NuGet packages that depend on Pure.HashCodes:
| Package | Downloads |
|---|---|
|
Pure.RelationalSchema.HashCodes
Package Description |
|
|
Pure.Chart.Model.HashCodes
Package Description |
|
|
Pure.Diagram.Model.HashCodes
Package Description |
|
|
Pure.Chart.RichRelationalModel.HashCodes
Package Description |
|
|
Pure.Chart.RelationalModel.HashCodes
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.