xxh3 1.0.1 copy "xxh3: ^1.0.1" to clipboard
xxh3: ^1.0.1 copied to clipboard

A Dart implementation (port) of the XXH3 hashing algorithm from xxHash.

dart-xxh3 #

Pub Publisher Pub Version GitHub Workflow Status Codecov GitHub

Port of the XXH3 hashing algorithm in Dart.

import 'dart:convert' show utf8;
import 'dart:typed_data';

import 'package:xxh3/xxh3.dart';

void main() {

  // Get the string as UTF-8 bytes.
  final bytes = utf8.encode("Hello, world!");
  
  // Use XXH3 to hash the byte array (returns an int).
  // XXH3 is a 64-bit hash, so the value is returned in the
  // form of an unsigned 64-bit integer.
  final int digest = xxh3(Uint8List.fromList(bytes));
  print(digest);
  
  // See the examples and documentation for more...
  
}

Refer to the Example tab for a 'quick start guide', or for more details refer to the API Documentation.

As it stands, this is a port written entirely in Dart. It should perform fairly well, but I have not benchmarked it as the main goal for this package is to have a compatible hash implementation in Dart. If better performance is needed, this could probably serve as a fallback and dart:ffi could be used to call native code for better performance.

This uses native integers for performance reasons, so this will not provide correct results for Dart web. If there is demand for this, that could probably be rectified.

4
likes
140
pub points
68%
popularity

Publisher

verified publishersamjakob.com

A Dart implementation (port) of the XXH3 hashing algorithm from xxHash.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

More

Packages that depend on xxh3