RapidHashSharp 1.0.0

dotnet add package RapidHashSharp --version 1.0.0
                    
NuGet\Install-Package RapidHashSharp -Version 1.0.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="RapidHashSharp" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="RapidHashSharp" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="RapidHashSharp" />
                    
Project file
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 RapidHashSharp --version 1.0.0
                    
#r "nuget: RapidHashSharp, 1.0.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 RapidHashSharp@1.0.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=RapidHashSharp&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=RapidHashSharp&version=1.0.0
                    
Install as a Cake Tool

RapidHashSharp

High-performance C# port of rapidhash V3 - a very fast, high quality, platform-independent hashing algorithm.

License: MIT

Features

  • Near-native performance: Achieves parity with C for inputs ≥128 bytes
  • Pure C#: No native dependencies, works on any .NET platform
  • Three hash variants: General purpose, HPC-optimized, and minimal code size
  • Fully tested: 223 compatibility tests ensure identical output to original C implementation

Performance

Size C# Throughput vs Native C
32 bytes 6.9 GB/s 78%
128 bytes 12.6 GB/s 97%
512 bytes 18.0 GB/s 104%
1 KB+ 19-21 GB/s 108-110%

C# is actually faster than C for large inputs due to .NET's optimized Math.BigMul intrinsic.

See BENCHMARKS.md for detailed benchmarks.

Installation

dotnet add package RapidHashSharp

Usage

using RapidHashSharp;

// Hash a byte array or span
byte[] data = "Hello, World!"u8.ToArray();
ulong hash = RapidHash.Hash(data);

// With a custom seed
ulong seededHash = RapidHash.HashWithSeed(data, seed: 12345);

// For maximum performance with pointers (unsafe)
unsafe {
    fixed (byte* ptr = data) {
        ulong hash = RapidHash.Hash(ptr, (nuint)data.Length);
    }
}

Hash Variants

Function Best For Notes
Hash General purpose Best performance across all sizes
HashMicro HPC/Server Faster for ≤512 bytes, smaller code
HashNano Mobile/Embedded Fastest for ≤48 bytes, smallest code

All variants produce identical output for small inputs (≤48-80 bytes depending on variant).

API

// Span-based API (recommended)
ulong Hash(ReadOnlySpan<byte> data)
ulong HashWithSeed(ReadOnlySpan<byte> data, ulong seed)
ulong HashMicro(ReadOnlySpan<byte> data)
ulong HashNano(ReadOnlySpan<byte> data)

// Pointer-based API (maximum performance)
ulong Hash(byte* data, nuint length)
ulong HashWithSeed(byte* data, nuint length, ulong seed)
ulong HashMicro(byte* data, nuint length)
ulong HashNano(byte* data, nuint length)

Credits

  • Original rapidhash algorithm: Nicolas De Carli
  • Based on: wyhash by Wang Yi
  • C# port: AI-assisted development with GitHub Copilot

License

MIT License - see LICENSE for details.

The original rapidhash algorithm is also MIT licensed.

See Also

Product Compatible and additional computed target framework versions.
.NET 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.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 137 1/16/2026