Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hazae41/sha1
SHA-1 adapter for WebAssembly and JS implementations
https://github.com/hazae41/sha1
browser cryptography hashing javascript noble sha1 typescript webassembly
Last synced: about 1 month ago
JSON representation
SHA-1 adapter for WebAssembly and JS implementations
- Host: GitHub
- URL: https://github.com/hazae41/sha1
- Owner: hazae41
- Created: 2023-03-26T17:45:31.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-08-31T15:59:22.000Z (3 months ago)
- Last Synced: 2024-10-11T21:31:39.181Z (about 1 month ago)
- Topics: browser, cryptography, hashing, javascript, noble, sha1, typescript, webassembly
- Language: TypeScript
- Homepage:
- Size: 72.3 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
Awesome Lists containing this project
README
# Sha1
SHA-1 adapter for WebAssembly and JS implementations
```bash
npm i @hazae41/sha1
```[**Node Package 📦**](https://www.npmjs.com/package/@hazae41/sha1)
## Features
### Current features
- 100% TypeScript and ESM
- No external dependencies## Getting started
### WebAssembly
```bash
npm i @hazae41/sha1.wasm
``````typescript
import { Sha1 } from "@hazae41/sha1"
import { Sha1Wasm } from "@hazae41/sha1.wasm"await Sha1Wasm.initBundled()
Sha1.set(Sha1.fromWasm(Sha1Wasm))
```### Noble (JavaScript)
```bash
npm i @noble/hashes
``````typescript
import { Sha1 } from "@hazae41/sha1"
import Sha1Noble from "@noble/hashes/sha1"Sha1.set(Sha1.fromNoble(Noble))
```## Usage
### Direct
```tsx
using hashed: Copiable = Sha1.get().getOrThrow().hashOrThrow(new Uint8Array([1,2,3,4,5]))
const hashed2: Uint8Array = hashed.bytes.slice()
```### Incremental
```tsx
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()
```