1.0.3 • Published 11 months ago
@hazae41/ripemd160 v1.0.3
Ripemd160
RIPEMD-160 adapter for WebAssembly and JS implementations
npm i @hazae41/ripemd160
Features
Current features
- 100% TypeScript and ESM
- No external dependencies
Getting started
WebAssembly
npm i @hazae41/ripemd.wasm
import { Ripemd160 } from "@hazae41/ripemd160"
import { RipemdWasm } from "@hazae41/ripemd.wasm"
await RipemdWasm.initBundled()
Ripemd160.set(Ripemd160.fromWasm(RipemdWasm))
Noble (JavaScript)
npm i @noble/hashes
import { Ripemd160 } from "@hazae41/ripemd160"
import Ripemd160Noble from "@noble/hashes/ripemd160"
Ripemd160.set(Ripemd160.fromNoble(Ripemd160Noble))
Usage
Direct
using hashed: Copiable = Ripemd160.get().getOrThrow().hashOrThrow(new Uint8Array([1,2,3,4,5]))
const hashed2: Uint8Array = hashed.bytes.slice()
Incremental
using hasher: Ripemd160.Hasher = Ripemd160.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()