Keccak-256 adapter for WebAssembly and JS implementations
npm i @hazae41/keccak256
- 100% TypeScript and ESM
- No external dependencies
npm i @hazae41/sha3.wasm
import { Keccak256 } from "@hazae41/keccak256"
import { Sha3Wasm } from "@hazae41/sha3.wasm"
await Sha3Wasm.initBundled()
Keccak256.set(Keccak256.fromWasm(Sha3Wasm))
npm i @noble/hashes
import { Keccak256 } from "@hazae41/keccak256"
import Sha3Noble from "@noble/hashes/sha3"
Keccak256.set(Keccak256.fromNoble(Sha3Noble))
using hashed: Copiable = Keccak256.get().getOrThrow().hashOrThrow(new Uint8Array([1,2,3,4,5]))
const hashed2: Uint8Array = hashed.bytes.slice()
using hasher: Keccak256.Hasher = Keccak256.get().getOrThrow().Hasher.createOrThrow()
hasher.updateOrThrow(new Uint8Array([1,2,3,4,5]))
hasher.updateOrThrow(new Uint8Array([6,7,8,9,10]))
using hashed: Copiable = hasher.finalizeOrThrow()
const hashed2: Uint8Array = hashed.bytes.slice()