blake3_dart 1.0.0
blake3_dart: ^1.0.0 copied to clipboard
A pure Dart implementation of the BLAKE3 cryptographic hash function.
blake3_dart #
Pure Dart implementation of BLAKE3 — a fast, secure cryptographic hash function.
- 256-bit output (with arbitrary-length XOF support)
- Keyed mode (MAC)
- Key derivation (KDF)
- 100% compliance with the official 291 test vectors
- Zero dependencies
- Works on Dart VM, Flutter, web (WASM), etc.
Installation #
With Dart:
dart pub add blake3_dart
With Flutter:
flutter pub add blake3_dart
Examples #
import 'dart:convert';
import 'package:blake3_dart/blake3_dart.dart';
void main() {
// 1. Standard (unkeyed) hash
final input = utf8.encode('hello');
print(blake3Hex(input));
// → eaabf7da0d2298e8b5c1203e2f9f7d8c8d8d8d8d... (64 hex chars = 256 bits)
// Empty input (known test vector)
print(blake3Hex(Uint8List(0)));
// → af1349b9f5f9a1a6a0404dea36dcc9499bcb25c9adc112b7cc9a93cae41f3262
// 2. Keyed hash (MAC mode)
final key = Uint8List.fromList(List.generate(32, (i) => i)); // example 32-byte key
print(blake3KeyedHex(key, utf8.encode('secret message')));
// → some 64-char hex string
// 3. Key derivation (KDF mode)
final context = 'my-app:2025:v1';
final keyMaterial = utf8.encode('user123:sessiontoken');
print(blake3DeriveKeyHex(
context: context,
keyMaterial: keyMaterial,
));
// → another 64-char hex string (deterministic subkey)
}
See tests for examples of additional supported functionality
Running Tests #
dart test
Licensing #
MIT License
Author #
Knut-Arve K. Meldahl (Email: yoshiki@vecnofoundation.org)
Contributing #
Contributions are welcome.