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

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

example/main.dart

import 'dart:convert' show utf8;

import 'package:xxh3/xxh3.dart';

void main() {
  // Get the string as UTF-8 bytes.
  final helloWorldBytes = 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 a 64-bit integer.
  final int digest = xxh3(helloWorldBytes);
  print(digest); // -881777603154417559

  // Alternatively, in version 1.1.0+, you can use the
  // xxh3String convenience method to get a hexadecimal
  // string representation of the hash.
  final String hexDigest = xxh3String(helloWorldBytes);
  print(hexDigest); // f3c34bf11915e869

  // Similarly, in version 1.2.0+, you can use the
  // stream API to process your data in blocks.
  final hashStream = xxh3Stream();
  hashStream.update(helloWorldBytes);
  print(hashStream.digest()); // -881777603154417559
  print(hashStream.digestString()); // f3c34bf11915e869

  // See the examples and documentation for more...
}
5
likes
160
points
74.3k
downloads

Publisher

verified publishersamjakob.com

Weekly Downloads

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