json-cipher-value

3.0.1 • Public • Published

JSON Cipher Value

NPM version JavaScript Style Guide Maintainability

json-cipher-value is a simple (de)ciphering module for node.js that recursively performs encryption of the values of object/json files retaining their types.

Note:

  • This module is based on the build-in crypto node module,
  • Default settings perform an aes-256-ctr ciphering,
  • An iv is randomly generated for each value.

Furthermore, it is provided with a CLI in order to simply cipher json files.

Table of Contents

Install

npm install json-cipher-value

Usage

import createCipherObject from 'json-cipher-value'

const secret = 'My secret password'
const cipherObject = createCipherObject(secret)

const object = {
  a: 'a value',
  b: {
    a: [1, 3.1, '2.2', true, true, false]
  }
}

const cipheredObject = cipherObject.perform('cipher', object)
//{
//  a: '35747569f964d575521a0205b8d21af8eab60b69c30d2fe5',
//  b: {
//    a: [
//        '7f7e507e96b07807661d6e531f6b4e489205',
//        'a6af3a7c1d52a8163a196c4487256c584a0943e9',
//        'eed2d3bf77a9d0fa51449268dc6c1553fd6257ba',
//        'bf0fca31bf46d5611899cf9e53f49f28d317bebcf8',
//        '10c58a69fd3bcf904cf5860e423d081cf6d2646227',
//        'dda317d5e23e5f14423c44ee46b9bf49c762ee23ed49'
//    ]
//  }
//}

const decipheredObject = cipherObject.perform('decipher', cipheredObject)
// { a: 'a value', b: { a: [ 1, 3.1, '2.2', true, true, false ] } }

CLI

This module is provided with a CLI in order to simply cipher json files:

  • It performs (de)ciphering with the default algorithm used by this package i.e. the aes-256-ctr one's,
  • It optionnally allows modifying ciphered file extension (.cjson as default) or target folder.
cipher-json cipher src/data/**/*.json 'My secret password'
cipher-json decipher src/data/**/*.cjson 'My secret password'

Use -h for further details/available options.

API

See API.md for more details.

Tests

Typing:

npm run test

will launch a set of unit and functional tests as well as checking the compliancy of code with standardjs.

Credits

License

This module is MIT licensed. See LICENSE.

Package Sidebar

Install

npm i json-cipher-value

Weekly Downloads

0

Version

3.0.1

License

MIT

Unpacked Size

24.9 kB

Total Files

11

Last publish

Collaborators

  • nbarikipoulos