https://github.com/ecies/rs-wasm
A WASM binding for eciesrs
https://github.com/ecies/rs-wasm
ecies rust wasm
Last synced: over 1 year ago
JSON representation
A WASM binding for eciesrs
- Host: GitHub
- URL: https://github.com/ecies/rs-wasm
- Owner: ecies
- License: mit
- Created: 2020-12-06T15:21:03.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-04-30T14:51:41.000Z (about 2 years ago)
- Last Synced: 2024-09-19T08:38:14.393Z (almost 2 years ago)
- Topics: ecies, rust, wasm
- Language: Rust
- Homepage: https://ecies-wasm.vercel.app/
- Size: 35.2 KB
- Stars: 16
- Watchers: 3
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# ecies-wasm
[](https://github.com/ecies/rs-wasm)
[](https://www.npmjs.com/package/ecies-wasm)
[](https://npm-stat.link/ecies-wasm)
[](https://packagephobia.com/result?p=ecies-wasm)
[](https://github.com/ecies/rs-wasm/actions)
A WASM binding for [eciesrs](https://github.com/ecies/rs).
## Install
```bash
npm install ecies-wasm
```
## Usage
```js
import init, * as ecies from "ecies-wasm";
const encoder = new TextEncoder();
const decoder = new TextDecoder();
// if built with vite without plugin
// can also run with bun/deno
init().then(() => {
const [sk, pk] = ecies.generateKeypair();
const data = encoder.encode("hello ecies🔒");
const encrypted = ecies.encrypt(pk, data);
const decrypted = decoder.decode(ecies.decrypt(sk, encrypted));
console.log("decrypted: " + decrypted);
});
```
Check [the example](./example) for how to use it in browsers.
## API
```ts
export function generateKeypair(): Uint8Array[]; // [sk, pk]
export function encrypt(pk: Uint8Array, msg: Uint8Array): Uint8Array;
export function decrypt(sk: Uint8Array, msg: Uint8Array): Uint8Array;
```
## Build and test
```bash
wasm-pack build
wasm-pack build --target web
wasm-pack test --node
```
## Changelog
See [CHANGELOG.md](./CHANGELOG.md).