Git Product home page Git Product logo

json-cipher-value's Introduction

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.

json-cipher-value's People

Contributors

nbarikipoulos avatar

Stargazers

 avatar

Watchers

 avatar

json-cipher-value's Issues

Update dependencies/Fix CVE

Update dependencies of the project.
In particular, bump vynil-fs to its latest release to fix various CVE

Simplify/Redesign internal cipher objects

Simplfy cipher objects:

  • Merge CipherData and CipherObject,
  • Replace the encrypt(d)/decrypt(d) functions with a single perfom(action, data) entry point where:
    • action ='cipher' | 'decipher'
    • data: is supported primitive types or object/array (ciphering case).

Update vocabulary/terminology used in internal code:

  • use prefix cipher/decipher for crypt/encrypt objects,
  • ciphertext instead of crypted,
  • and so on.

Remove useless config settings 'isTyped'

In config object, remove the settings option 'isTyped' which allows not retaining the type of value.

As its default value was true, it will not change current use with default settings.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.