Git Product home page Git Product logo

crypto-json's Introduction

Looking for a new maintainer

crypto-json Build Status js-standard-style

Recursively encrypt/decrypt objects selectively by keys.

Installation

$ npm install crypto-json --save

Usage

const cryptoJSON = require('crypto-json')

cryptoJSON.encrypt(object, password, [config]) => encryptedObject

cryptoJSON.decrypt(encryptedObject, password, [config]) => object

password

Random password, length according to the selected algorithm, e.g. 32 bytes length with aes-256-cbc.

config (optional)

  • algorithm - select any supported by the version of Node you are using (default: aes-256-cbc)
  • encoding - hex, base64, binary (default: hex)
  • keys - specify which keys to encrypting/decrypting (default: [], i.e. encrypt/decrypt everything)

Example

const util = require('util')
const cryptoJSON = require('crypto-json')
const algorithm = 'aes-256-cbc'
const encoding = 'hex'

const input = {
  hello: {
    bar: ['hello', 'world'],
    baz: {
      secret: 'hide a secret',
      b: {test: 1}
      }
    }
  }

const password = 'random password 32 bytes length.'

// keys act like a white list, so for example if you want to encrypt a nested
// key "secret" you also need to specify its parent keys,
// i.e. "secret", "baz", "hello" in the above input object

const keys = ['hello', 'baz', 'secret']

const output = cryptoJSON.encrypt(
  input, password, {encoding, keys, algorithm}
)
console.log(util.inspect(input ,{showHidden: false, depth: null, colors: true}))
console.log(util.inspect(output ,{showHidden: false, depth: null, colors: true}))

/*

{
  hello: {
    bar: [ 'hello', 'world' ],
    baz: {
      secret: 'b2114cc78fcee8c58a14ba2df511dd05:e5a58d9b9eaab60ca0830d1c7ad4fd41',
      b: { test: 1 }
    }
  }
}
*/

crypto-json's People

Contributors

perugini avatar roryrjb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

crypto-json's Issues

primitive arrays not encrypted when keys is set

Hi,
I found two issues
first:
if options.key is present, then arrays with primitive objects are not encrypted anymore
example

var o = cryptoJson.encrypt({
intents: [{intent: 'kreditkarte_eingeben', confidence: 1}],
entities: [],
input: {text: 'ich möchte mit Kreditkarte bezahlen'},
output: {
text: ['Ich habe momentan keine Information über Deinen Auftrag. Die Eingabe der Kreditkarte ist daher auf diesem Weg nicht möglich.'],
nodes_visited: ['Kreditkarte_eingeben', 'node_2_1499429704640']
}, {keys: 'intent'});

encrypts to
{
intents: [{intent: 'kreditkarte_eingeben', confidence: 1}],
entities: [],
input: {text: '4693a65d6514d8f0fc89d536b8ec1d23db35d9677b5268747b986146f2d1e2d8'},
output: {
text: ['Ich habe momentan keine Information über Deinen Auftrag. Die Eingabe der Kreditkarte ist daher auf diesem Weg nicht möglich.'],
nodes_visited: ['Kreditkarte_eingeben', 'node_2_1499429704640']
}

Please change line 34 to
if (!keys.length || (keys.indexOf(key) === -1)) {

second

the parameter options is not optional

see lines 54 and 72

Thank you

support React Native

I am looking for a way to validate JSON objects.
Can I was this library to encrypt/decrypt JSON object in React Native app?

Looking for new maintainer

I don't use this module anymore, and to be honest I don't even use Node.js or GitHub much anymore, and I don't have the time to update it, review issues or pull requests, so I am looking for a new maintainer. I won't just pick anyone, as people are using the module, so I have to ensure it goes into good hands. If no one suitable comes forward (in a reasonable amount of time) I will deprecate the module in npm and archive the repo in GitHub.

Breaking change from 2.0.0 to 2.0.1

We'd been using 2.0.0 without issue for some time.

When I went to update our packages, I updated this to 2.0.1 - now it isn't working.

{cipher: 'camellia-128-cbc', passKey: 'xxx', encoding: 'hex'};`` is our setup

This is the error I get:

error:0606506D:digital envelope routines:EVP_DecryptFinal_ex:wrong final block length

Perhaps a dependency needs to be updated?

Reverting back to 2.0.0 fixed the issue, which I will do in the meantime.

create-react-app fails to minify

When using this library in a create-react-app application, yarn run react-build fails with the error message:

Failed to minify the code from this file:
./node_modules/crypto-json/index.js:5

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.