A5Hash.Sharp
1.1.0
dotnet add package A5Hash.Sharp --version 1.1.0
NuGet\Install-Package A5Hash.Sharp -Version 1.1.0
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="A5Hash.Sharp" Version="1.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="A5Hash.Sharp" Version="1.1.0" />
<PackageReference Include="A5Hash.Sharp" />
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 A5Hash.Sharp --version 1.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: A5Hash.Sharp, 1.1.0"
#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.
#:package A5Hash.Sharp@1.1.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=A5Hash.Sharp&version=1.1.0
#tool nuget:?package=A5Hash.Sharp&version=1.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
A5Hash.Sharp
High-performance, AI-assisted C# port of the original a5hash family of hash functions by Aleksey Vaneev.
- Upstream repo: https://github.com/avaneev/a5hash
- Upstream author: Aleksey Vaneev (2025), MIT licensed
This library provides:
A5Hash.Hash(64-bit)A5Hash.Hash32(32-bit)A5Hash.Hash128(128-bit)
a5hash is a fast non-cryptographic hash intended for hash tables / bloom filters (not a cryptographic primitive).
Install
NuGet
dotnet add package A5Hash.Sharp
Source
Copy src/A5Hash/A5Hash.cs into your project and enable AllowUnsafeBlocks.
Usage
using A5Hash;
ReadOnlySpan<byte> data = "Hello, World!"u8;
ulong h64 = A5Hash.Hash(data);
uint h32 = A5Hash.Hash32(data);
var (low, high) = A5Hash.Hash128(data);
// Optional seed (recommended when hashing attacker-controlled keys)
ulong seeded = A5Hash.Hash(data, seed: 0xDEADBEEFCAFEBABE);
Hashing a slice (zero allocations)
byte[] buffer = new byte[1024];
ulong hash = A5Hash.Hash(buffer.AsSpan(0, 256));
Benchmarks (short)
Full tables are in benchmarks.md and include:
- Native C vs C# (same algorithm)
- C# vs hardware-accelerated CRC32 (
System.IO.Hashing.Crc32)
Highlights from the latest run (see benchmarks.md for details):
- 64-bit throughput (1MB): ~5.9 GB/s (C#) vs ~5.6 GB/s (native C)
- 4-byte throughput (ops/s): a5hash32 ~368M ops/s vs HW CRC32 ~217M ops/s
Requirements
- Targets net8.0 and net10.0
AllowUnsafeBlocks=true
Credits
- Original algorithm + C implementation: https://github.com/avaneev/a5hash by Aleksey Vaneev
- This repo: AI-assisted port + performance work
License
MIT — see LICENSE.
| 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 was computed. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- No dependencies.
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.