npm install @rotko/blake3 # Pure JS - works everywhere npm install @rotko/blake3-wasm # WASM + Rayon - fastest, needs COOP/COEP headers npm install @rotko/blake3-auto # Auto-selects best available
import { blake3 } from '@rotko/blake3';
const data = new TextEncoder().encode('hello world');
const hash = blake3(data);
console.log(blake3.hex(data)); // hex string
Click "Run Example" to see output
import { init, blake3, blake3Parallel } from '@rotko/blake3-wasm';
await init(); // or init(8) for 8 threads
const hash = blake3(data); // single-threaded WASM
const hashPar = blake3Parallel(data); // multi-threaded with Rayon
Note: WASM package requires COOP/COEP headers for multi-threading. See benchmark for full example.
import { init, blake3, getBackend } from '@rotko/blake3-auto';
await init(); // auto-detects best backend
const hash = blake3(data);
console.log(getBackend()); // 'wasm-rayon', 'wasm', or 'js'
This demo uses pure JS mode. When you install via npm and bundle with your app, @rotko/blake3-auto will automatically use the faster WASM backend if your server sends the required COOP/COEP headers.
Initializing...