Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
axetroy committed May 13, 2023
1 parent 8f0fc53 commit deff59e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 16 deletions.
15 changes: 13 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
[package]
name = "hasher"
name = "wasm-hasher"
version = "0.1.0"
authors = ["Axetroy <axetroy.dev@gmail.com>"]
edition = "2021"
repository = "https://github.com/axetroy/wasm-hasher"
readme = "README.md"
description = "A wasm module for Hash"
description = "computed data hash by webAssembly support md5,sha1,sha2,sha3,sm3"
license = "Anti-996"
keywords = [
"md5",
"sha",
"sha1",
"sha2",
"sha3",
"sha256",
"sha512",
"wasm",
"webassembly",
]

[lib]
crate-type = ["cdylib", "rlib"]
Expand Down
5 changes: 1 addition & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
.DEFAULT:
build:
@wasm-pack build --release --target web --out-dir out/web
@wasm-pack build --release --target nodejs --out-dir out/nodejs
@wasm-pack build --release --target no-modules --out-dir out/no-modules
@wasm-pack build --release --target bundler --out-dir out/bundler
@wasm-pack build --release --target bundler --scope axetroy --out-dir out
24 changes: 14 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,30 @@

</div>

## Usage
The difference with [github.com/fuyoo/wasm-hasher](https://github.com/fuyoo/wasm-hasher)

```bash
1. Hash process can be interrupted with `abortController`
2. The exposed function can specify the chunks size for each read. Larger chunks use more CPU.
3. `onProgress` callback is optional. Set to `null` to improve performance if you don't need it.

## Usage

```js
import("@axetroy/wasm-hasher").then(({ default: hasher }) => {
const controller = new abortController();
const file = new Blob([], { type: "application/text" });
hasher.md5(controller.signal, file, 1024 * 1024 * 10, (progress) => {
console.log("hash progress");
});
});
```

## 🚴 Installation

1. if you are using Bundler(Which build-in support to importing wasm module, eg. Webpack^5/Vite)

```bash
npm install @axetroy/wasm-hasher
```

```js
import("@axetroy/wasm-hasher");
```

2. If you are using in Native browser

### 🛠️ Build from source

Make sure you have install [rust^1.69](https://www.rust-lang.org/) and [wasm-pack](https://rustwasm.github.io/wasm-pack/installer/)
Expand Down

0 comments on commit deff59e

Please sign in to comment.