Hashing & KDF
@webbuf/blake3
Rust/wasm optimized blake3 hash & mac
Install
npm install @webbuf/blake3 Usage
import { blake3Hash, doubleBlake3Hash, blake3Mac } from "@webbuf/blake3";
import { WebBuf } from "@webbuf/webbuf";
import { FixedBuf } from "@webbuf/fixedbuf";
// Hash data
const data = WebBuf.fromUtf8("Hello, world!");
const hash = blake3Hash(data);
console.log(hash.toHex()); // 32-byte hash
// Double hash (hash of hash)
const doubleHash = doubleBlake3Hash(data);
// Keyed MAC (requires 32-byte key)
const key = FixedBuf.fromRandom<32>(32);
const mac = blake3Mac(key, data);
console.log(mac.toHex()); // 32-byte MAC API reference (3 exports)
Functions
blake3Hash
functionblake3Hash(buf: WebBuf): FixedBuf<32> blake3Mac
functionblake3Mac(key: FixedBuf<32>, message: WebBuf): FixedBuf<32> doubleBlake3Hash
functiondoubleBlake3Hash(buf: WebBuf): FixedBuf<32>