README
wmt-encryption
The wmt-encryption module provides aes-256-gcm encryption for JavaScript applications.
Setting up the module
- git clone git@bitbucket.org:wmtp/wmt-encryption.git
- cd wmt-encryption
- npm install
Building the module
The module uses Typescript compiler (TSC) to compile the source code. To build the project run the following command:
- npm run build
Installing the module for testing
You can install the module into your own JavaScript project as a dependency. After you clone the module you can install using the following command:
- npm install /absolute/path/to/wmt-encryption
- i.e. -> npm install /Users/wmt/Documents/projects/npm/wmt-encryption
Installing the module from npm
Use the following command to install from npm:
- npm install wmt-encryption
Importing the module
Once you have the module installed you can import exported functions into your code like so:
import {generateKeyFromString, encrypt, decrypt} from "wmt-encryption";
Using the module
Example of using the module:
// import the module
import {generateKeyFromString, encrypt, decrypt} from "wmt-encryption";
// create something
let somePlainText = "some plain text";
// generate key from some pin
let key = generateKeyFromString("1234");
// encrypt data
let encryptedText = encrypt(somePlainText, key); // encryptedText: "6dd34283b31adfa7fd5ec507d72e33b9"
// decrypt data
let decryptedText = decrypt(encryptedText, key); // decryptedText: "some plain text"
Testing
- Tests can be ran with the
npm test
command. - Tests are ran using Jest - More information about getting started with Jest can be found here.
Viewing API docs
Here you can find the API docs that detail all functions of this module: https://wmtp.bitbucket.io/TypescriptModules/docs/wmt-encryption/docs
Viewing the source code
https://bitbucket.org/wmtp/wmt-encryption
Published module
Here is where the module is currently published: https://www.npmjs.com/package/wmt-encryption
License
This project is licensed under the MIT License.