A standalone cryptographic primitive wrapper library that can be included in various projects across a variety of development environments, including:
It wraps gibme-c/crypto and exposes much of the functionality of that package to the supported development environments.
Note: Due to the size of the resulting WASM/Javascript module(s), only English mnemonic words are compiled by default.
Note: If you are looking to use this package in a browser, please read the browser directions below for a lighter installation path and minimal package size.
Prebuilds of the Node.js native addon module and WASM/JS binaries are included with the npm-distributed package. If a prebuild for your platform does not exist, the native addon will be compiled automatically via CMake.
yarn add @gibme/crypto
npm install @gibme/crypto
import Crypto from '@gibme/crypto';
const crypto = await Crypto.init();
const Crypto = require('@gibme/crypto').default;
const crypto = await Crypto.init();
By default, the library selects the best available module (native > WASM > JS). You can override this:
import Crypto from '@gibme/crypto';
const crypto = await Crypto.init();
// Force WASM module
await Crypto.force_wasm_library();
// Force JS (asm.js) module
await Crypto.force_js_library();
The package provides subpath exports for directly importing specific module loaders:
import Crypto from '@gibme/crypto/wasm'; // WASM loader
import Crypto from '@gibme/crypto/asm'; // asm.js loader
import Crypto from '@gibme/crypto/node'; // Native addon loader
For browser environments, use the dedicated browser package which provides a lighter installation without the native C++ addon.
yarn add @gibme/crypto-browser
npm install @gibme/crypto-browser
import Crypto from '@gibme/crypto-browser';
const crypto = await Crypto.init();
const Crypto = require('@gibme/crypto-browser').default;
const crypto = await Crypto.init();
Full TypeScript/JS API documentation is available at gibme-npm.github.io/crypto.
External references are provided via libraries in the Public Domain (Unlicense), MIT, and/or BSD from their respective parties.
This wrapper library is provided under the BSD-3-Clause license found in the LICENSE file.
Please make sure when using this library that you follow the licensing requirements set forth in all licenses.