small package to store key/value with encrypted data
this could be used in both the browser and node.js
npm i use-storage-node
npm run test
import storage from "use-storage-node";
const person = {
name: "jhon doe",
location: "tunisia",
job: "fullstak",
};
const token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
const private_key = "xlqsdeidhe";
// should be in .env
const store = storage(private_key);
// ADD ITEM TO STORAGE
store.setItem("person", person);
store.setItem("token", token);
// GET ITEM FROM STORAGE
const item = store.getItem("person");
// REMOVE ITEM FROM STORAGE
store.removeItem("token");
// CLEAR STORAGE
store.clear();
store(cryptoKey:string) -> {}
const store = store(private_key); // returns {}
// prepare an empty object to store key/value pair
// private key used to encrypte data
// private key should be stored in .env
addItem(key:string,value:any) -> undefined
store.addItem(key,value);
// store now container key / value pair with encrypted value
// value could be of any type
getItem(key:string) -> value
store.getItem(key,value);
// return decrypted value
removeItem(key:string) -> store
store.removeItem(key);
// store now container key / value pair with encrypted value
clear() -> undefined
store.clear();
// clear all key/value pair
adnen rebai
This package is released under the MIT license.