SamJakob / xxh3

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

Home Page:https://pub.dev/packages/xxh3

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

dart-xxh3

Pub Publisher Pub Version GitHub Workflow Status Codecov MIT License

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.

About

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

https://pub.dev/packages/xxh3

License:MIT License


Languages

Language:Dart 97.5%Language:Shell 2.5%