ncryptify

0.0.6 • Public • Published

NCryptify Client node.js Library

This node.js library provides access to the ncryptify service. The ncryptify service offers key management as a service, and specialised cryptography such as format preserving encryption as a service. Visit www.ncryptify.com for more information.

Features

  • Hide/Unhide digital, alphanumeric, or plain printable text while preserving format using the ncryptify crypto service.
  • Create and retrieve cryptographic keys using the ncryptify key management service. These retrieved keys can subsequently be used to perform the cryptographic operations enumerated below.
  • Encrypt and decrypt buffers (also called blobs) using local encryption provided by the node.js crypto library.
  • Encrypt and decrypt files using local encryption provided by the node.js crypto library.

Installation

To install this module for use within node.js applications, use the following npm install command.

$ npm install ncryptify

Note: ncryptify requires node v4.2.2 or higher.

Documentation

API Documentation can be found in doc/index.html. You can always regenerate the documentation using grunt jsdoc.

Get a client ID and client secret

Go to https://devportal.ncryptify.com/ and get a client id and secret. You can do this by creating a new application. Note down the client ID and client secret for the app after it has been created.

Play with it

var ncryptify = require('ncryptify');
...

var HideParams = {keyName: "phone-number", hint: "digit"};
 
var ncryptifyClient = new ncryptify.Client(CLIENT_ID, CLIENT_SECRET, CLIENT_ISSUER, 5, "billy@yourapp.net");
ncryptifyClient.hide("555-123-4567", HideParams).then(function(value) {
    console.log("ncryptified number is " + value);
});

The CLIENT_ID and CLIENT_SECRET are the ones obtained from the developer portal as discussed above. The CLIENT_ISSUER can be any string you want.

Browser Version

Ncryptify can also be used in browsers. The browserified version is available in the scripts directory.

After making the changes to the library, execute the following command to apply the changes to the browser version.

npm run browserify-minify

This would create browserified and minified version of the library. The following files would be created as a result.

/scripts/browser-ncryptify.js
/scripts/browser-ncryptify.min.js
/examples/formfiller/public/scripts/browser-ncryptify.min.js

These files have to be manually committed.

Testing

The tests can be run from the root directory ('npm test' or 'mocha'). The tests require a client ID and secret. The environment variables, NCRYPTIFY_ID and NCRYPTIFY_SECRET, can be used to pass the client ID and client secret to the tests. These variables should be initialized using the client ID and secret obtained from the developer portal as follows:

NCRYPTIFY_ID=<client-id>
NCRYPTIFY_SECRET=<client-secret>

Add the environment variable NCRYPTIFY_HTTP_PROXY to setup HTTP proxy.

NCRYPTIFY_HTTP_PROXY=<http-proxy-url>

The tests use the dotenv module so if you wish you can place these values in the root directory of the project, in .env file, and the tests will pick them up.

Examples

Demonstrated uses of this module and ncryptify services can be found in the examples directory.

The client ID and client secret are used by the example applications. The formfiller application, located in the examples/formfiller directory, needs a client ID and a client secret. The client ID and secret can be passed to the application using environment variables as discussed previously. One could create a file named .env in the examples/formfiller directory and set the NCRYPTIFY_ID and NCRYPTIFY_SECRET variables to the client ID and secret, respectively, in that file.

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i ncryptify

Weekly Downloads

7

Version

0.0.6

License

MIT

Last publish

Collaborators

  • hsharma001
  • james-fitzgerald
  • ncryptify