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

outdated

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

dart-xxh3 #

Port of the XXH3 hashing algorithm in Dart.

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

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.

5
likes
0
pub points
71%
popularity

Publisher

verified publishersamjakob.com

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

Repository (GitHub)
View/report issues

License

unknown (license)

More

Packages that depend on xxh3