Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sc0vu/js-keccak-tiny
Keccak tiny emscripten binding in javascript, including SHA-3/Keccak/Shake hash function.
https://github.com/sc0vu/js-keccak-tiny
cryptography hash keccak keccak-tiny sha3 shake wasm webassembly
Last synced: about 1 month ago
JSON representation
Keccak tiny emscripten binding in javascript, including SHA-3/Keccak/Shake hash function.
- Host: GitHub
- URL: https://github.com/sc0vu/js-keccak-tiny
- Owner: sc0Vu
- License: mit
- Created: 2019-03-15T10:25:55.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-12-08T18:58:37.000Z (almost 2 years ago)
- Last Synced: 2024-10-04T13:35:55.634Z (about 1 month ago)
- Topics: cryptography, hash, keccak, keccak-tiny, sha3, shake, wasm, webassembly
- Language: JavaScript
- Homepage: https://sc0vu.github.io/keccak.html
- Size: 902 KB
- Stars: 3
- Watchers: 4
- Forks: 0
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# js-keccak-tiny
[![CI](https://github.com/sc0Vu/js-keccak-tiny/actions/workflows/ci.yml/badge.svg)](https://github.com/sc0Vu/js-keccak-tiny/actions/workflows/ci.yml)
[![codecov](https://codecov.io/gh/sc0Vu/js-keccak-tiny/branch/master/graph/badge.svg)](https://codecov.io/gh/sc0Vu/js-keccak-tiny)Keccak tiny wasm binding in javascript.
# Keccak tiny
Keccak tiny is a c implementation of keccak, the original repository https://github.com/status-im/nim-keccak-tiny.
# Install
* install library
```BASH
$ npm install js-keccak-tiny
```# Build with emscripten
You can build keccak-tiny wasm yourself with emscripten. To konw how to install or setup emscripten on your computer, please check their documentation https://emscripten.org/docs/getting_started/index.html. I build two version of keccak-tiny - nodejs and web. The only difference between two version is that there is no file system in web version.
```BASH
$ sh build.sh
```After build wasm files, you should build javascript library again.
```BASH
$ npm run build
```# Usage
* Hash message
```JS
// for nodejs
const keccakHashAsync = require('js-keccak-tiny/dist/node-bundle')// for browser
const keccakHashAsync = require('js-keccak-tiny/dist/browser-bundle')const msg = Buffer.from('It works!', 'utf8')
// initialize the library
keccakTiny = await keccakHashAsync()let hash = keccakTiny.keccak256(msg)
// do something to hash...
```
# BenchmarkComputer: 2.2 GHz 6-Core Intel Core i7
```
$ node -v
v12.18.1> [email protected] start /Users/peterlai/Desktop/Projects/js-keccak-tiny/benchmarks
> node index.jsKeccak tiny (current) x 558,114 ops/sec ±1.68% (89 runs sampled)
Pure JS (keccak) x 288,401 ops/sec ±0.55% (97 runs sampled)
Pure JS (sha3) x 13,370 ops/sec ±1.57% (90 runs sampled)
Pure JS (js-sha3) x 280,340 ops/sec ±0.41% (94 runs sampled)
Buffer 0bytes: fastest is Keccak tiny (current)
Keccak tiny (current) x 15.01 ops/sec ±1.04% (42 runs sampled)
Pure JS (keccak) x 4.21 ops/sec ±2.51% (15 runs sampled)
Pure JS (sha3) x 0.18 ops/sec ±4.71% (5 runs sampled)
Pure JS (js-sha3) x 4.26 ops/sec ±1.81% (15 runs sampled)
Buffer 10MiB: fastest is Keccak tiny (current)
```# License
MIT