xxh3 0.0.2+1 xxh3: ^0.0.2+1 copied to clipboard
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.