Ivshti / linvodb3

Persistent database for Node.js/NW.js/Electron with MongoDB/Mongoose-like features and interface on top of LevelUp
MIT License
747 stars 71 forks source link

is there any way to encryption and decryption #64

Open chouguleds-zz opened 7 years ago

chouguleds-zz commented 7 years ago

@Ivshti is there any way that I can encrypt the database and decrypt it at the time of querying and show the result?

Ivshti commented 7 years ago

It was never envisioned that way, but since linvodb3 is only a middleware, so you can use an encrypted back-end store (key-value store) and you would achieve the goal

look for encrypted leveldown stores, as linvodb works with levelup

zxfrank commented 3 years ago

Hello,

has someone acheived any form of encryption? I think the most viable option is with encryptdown (there's not many)

what I came up with looks like this:

const db = new LinvoDB('my_datastore_name', {}, {
   store   : {
      db   : function () { //must be a function otherwise an error "db is not a funtion" is thrown
         return encryptdown(LevelDown('path_to_ds_custom_folder'), { jwk });
      } 
   } 
});

But when I insert data, I get an error (after having a "success" inserted:1)

cause: undefined
message: "IO error: lock path_to_ds_custom_folder/LOCK: already held by process"
name: "OpenError"
stack: "OpenError: IO error: lock path_to_ds_custom_folder/LOCK: already held by process
    at node_modules/levelup/lib/levelup.js:87:23
    at node_modules/deferred-leveldown/node_modules/abstract-leveldown/abstract-leveldown.js:41:14
    at node_modules/deferred-leveldown/deferred-leveldown.js:20:21
    at node_modules/encoding-down/node_modules/abstract-leveldown/abstract-leveldown.js:41:14
    at node_modules/abstract-leveldown/abstract-leveldown.js:38:14
    at node_modules/leveldown/node_modules/abstract-leveldown/abstract-leveldown.js:38:14"
type: "OpenError"
__proto__: Error
cause: undefined
message: undefined
name: "LevelUPError"
stack: "LevelUPError
    at createError (node_modules/errno/custom.js:44:29)
    at ce (node_modules/errno/custom.js:50:12)
    at Object.<anonymous> (node_modules/level-errors/errors.js:11:14)
    [...]
    at Object.<anonymous> (node_modules/@adorsys/encrypt-down/src/index.js:12:23)"
type: "LevelUPError"

anyone have an idea?