Skip to content

Latest commit

 

History

History
65 lines (44 loc) · 1.21 KB

README.md

File metadata and controls

65 lines (44 loc) · 1.21 KB

Keccak256

Keccak-256 adapter for WebAssembly and JS implementations

npm i @hazae41/keccak256

Node Package 📦

Features

Current features

  • 100% TypeScript and ESM
  • No external dependencies

Getting started

WebAssembly

npm i @hazae41/sha3.wasm
import { Keccak256 } from "@hazae41/keccak256"
import { Sha3Wasm } from "@hazae41/sha3.wasm"

await Sha3Wasm.initBundled()

Keccak256.set(Keccak256.fromWasm(Sha3Wasm))

Noble (JavaScript)

npm i @noble/hashes
import { Keccak256 } from "@hazae41/keccak256"
import Sha3Noble from "@noble/hashes/sha3"

Keccak256.set(Keccak256.fromNoble(Sha3Noble))

Usage

Direct

using hashed: Copiable = Keccak256.get().getOrThrow().hashOrThrow(new Uint8Array([1,2,3,4,5]))
const hashed2: Uint8Array = hashed.bytes.slice()

Incremental

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()