1.0.4 • Published 2 years ago

cryptographic-json-database v1.0.4

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

Cryptographic JSON Database

Simple and powerful tool that allows to encrypt and decrypt data in json database and save it to desired file. Package is available on, to install it run npm i cryptographic-json-database.

Logo

How to use

const cryptographicJsonDatabase = require("cryptographic-json-database")
const DB = new cryptographicJsonDatabase(
    "test.json", // file name 
    "utf-8", // encoding
    "aes", // algorithm used for encryption, other options are des and triple-des
    "bf3c199c2470cb477d907b1e0917c17b", //key
    "5183666c72eec9e4" // initial vector
);
  • File name can be named with any extension and it will contain only encrypted data.
  • Encoding is recommended to use "utf-8"
  • Posible encryption standards are aes, des and triple des

If you use AES provide following:

  • Key 32 character
  • Initial vector 16 character

If you use DES provide following:

  • Key 8 character
  • Initial vector 8 character

If you use Triple DES provide following:

  • Key 24 character
  • Initial vector 8 character

Read data from the JSON file

DB.read();

Remove data from the JSON file

To remove data, search for entry by passing arguments in array in format [key, value].

DB.remove(["userId", 1]);

Find data in the JSON file

To find data in the JSON file add arguments in format [key, value].

DB.find(["title", "New title"]);

Update data in the JSON file

To update entry in the JSON file, provide first array in format [key, value] to find entry in the JSON and then it is possible to add array of keys and values to update multiple values in the object.

DB.update(
  ["userId", 1],
  [
    ["completed", false],
    ["title", "New title"],
  ]
);

Append data to the JSON file

To append data, just call append function and provide object to add to JSON file.

DB.append({
  userId: 11,
  id: 10,
  title: "New title",
  completed: false,
});

Write (override) data in the JSON file

Adding new data or overriding is possible to do when calling write function and providing string of data.

DB.write(
  JSON.stringify([{
    userId: 10,
    id: 10,
    title: "New title",
    completed: false,
  }])
);
1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago