@hazae41/sha1
TypeScript icon, indicating that this package has built-in type declarations

1.1.14 • Public • Published

Sha1

SHA-1 adapter for WebAssembly and JS implementations

npm i @hazae41/sha1

Node Package 📦

Features

Current features

  • 100% TypeScript and ESM
  • No external dependencies

Getting started

WebAssembly

npm i @hazae41/sha1.wasm
import { Sha1 } from "@hazae41/sha1"
import { Sha1Wasm } from "@hazae41/sha1.wasm"

await Sha1Wasm.initBundled()

Sha1.set(Sha1.fromWasm(Sha1Wasm))

Noble (JavaScript)

npm i @noble/hashes
import { Sha1 } from "@hazae41/sha1"
import * as Noble from "@noble/hashes"

Sha1.set(Sha1.fromNoble(Noble))

Usage

Direct

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

Incremental

using hasher: Sha1.Hasher = Sha1.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()

Dependents (0)

Package Sidebar

Install

npm i @hazae41/sha1

Weekly Downloads

9

Version

1.1.14

License

MIT

Unpacked Size

80.9 kB

Total Files

36

Last publish

Collaborators

  • hazae41