Sha1
SHA-1 adapter for WebAssembly and JS implementations
npm i @hazae41/sha1
Features
Current features
- 100% TypeScript and ESM
- No external dependencies
Getting started
Morax (WebAssembly)
npm i @hazae41/morax
import { Sha1 } from "@hazae41/sha1"
Sha1.set(await Sha1.fromMorax())
Noble (JavaScript)
npm i @noble/hashes
import { Sha1 } from "@hazae41/sha1"
Sha1.set(Sha1.fromNoble())
Usage
Direct
const hashed: Uint8Array = Sha1.get().tryHash(new Uint8Array([1,2,3,4,5])).unwrap().copyAndDispose()
Incremental
const hasher = Sha1.get().Hasher.tryNew().unwrap()
hasher.tryUpdate(new Uint8Array([1,2,3,4,5])).unwrap()
const hashed: Uint8Array = hasher.tryFinalize().unwrap().copyAndDispose()