xxh3
1.2.0, released 2 years ago by samjakob.com
Pure‑Dart implementation of the XXH3 64‑bit non‑cryptographic hash algorithm.
WASM-ready
What it does
Provides functions to compute a 64‑bit XXH3 hash from byte arrays, a hexadecimal string representation, and a streaming API for incremental hashing. The implementation runs entirely in Dart without native code.
AI-written summary of version 1.2.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need a fast, deterministic hash for in‑memory data structures or caching.
- You prefer a pure‑Dart solution that works on all Flutter platforms without ffi.
- You want to hash large data in chunks using a stream API.
Skip it when
- Cryptographic security is required (XXH3 is not a crypto hash).
- You need a 128‑bit hash or other hash variants not supported.
- Running on web where Dart ints exceed 53‑bit precision may give incorrect results.
Strengths
- No native dependencies – works everywhere Dart runs.
- High throughput for a pure‑Dart implementation.
- Streaming API allows hashing of large or incremental data.
Weaknesses
- Not suitable for security‑critical hashing.
- Only 64‑bit output; no XXH3‑128 support yet.
- Potential integer precision issues on JavaScript/web platforms.
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 0
import 'dart:convert' show utf8;
import 'package:xxh3/xxh3.dart';
void main() {
final bytes = utf8.encode('Hello, world!');
final int hash = xxh3(bytes);
final String hex = xxh3String(bytes);
print(hash); // -881777603154417559
print(hex); // f3c34bf11915e869
}Alternatives
Packages that do the same job and could replace xxh3.
Works with
Packages commonly used together with xxh3: ones it builds on, ones built on it, and its own family.
- lean_builderBuilt on xxh3Lean Builder: a fast, efficient Dart build system for code generation
- clarity_flutterBuilt on xxh3Flutter SDK for Microsoft Clarity session replay, heatmaps and interaction analytics.
- isar_community_generatorBuilt on xxh3Code generator for the Isar Database to find and process classes annotated with @Collection.
- ndkBuilt on xxh3Dart library for building Nostr clients with relay discovery, caching and signing support.