webbuf_blake3
BLAKE3 cryptographic hash function for Rust and WebAssembly.
Installation
[]
= "0.13"
Usage
use ;
// Hash data
let data = b"Hello, world!";
let hash = blake3_hash.unwrap;
assert_eq!;
// Double hash (hash of hash)
let double_hash = double_blake3_hash.unwrap;
assert_eq!;
// Keyed MAC (key must be exactly 32 bytes)
let key = ;
let mac = blake3_mac.unwrap;
assert_eq!;
API
| Function | Description |
|---|---|
blake3_hash(data: &[u8]) -> Result<Vec<u8>, String> |
Compute BLAKE3 hash (32 bytes) |
double_blake3_hash(data: &[u8]) -> Result<Vec<u8>, String> |
Compute hash of hash |
blake3_mac(key: &[u8], data: &[u8]) -> Result<Vec<u8>, String> |
Compute keyed MAC (key must be 32 bytes) |
WebAssembly
Build with the wasm feature for WebAssembly support:
[]
= { = "0.13", = ["wasm"] }
The TypeScript wrapper is available as @webbuf/blake3 on npm.
License
MIT