Skip to content
pubscout

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
$ flutter pub add xxh3
Source repository

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.

  • crypto

    Provides a wide range of cryptographic hash functions (e.g., SHA‑256) and works without native code, useful when security is required.

Works with

Packages commonly used together with xxh3: ones it builds on, ones built on it, and its own family.