Skip to content
GiantDB middleware for object encryption
JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
test
.codeclimate.yml
.eslintrc
.gitattributes
.gitignore
.travis.yml
LICENSE
README.md
index.js
package-lock.json
package.json

README.md

giantdb-crypto

Build Status Test Coverage Maintainability

GiantDB middleware for object encryption

Install

npm install --save giantdb-crypto

Setup

Example:

const GiantDB = require("giantdb");
const GiantDBCrypto = require("giantdb-crypto");

const db = new GiantDB();

// register the middleware
db.use(new GiantDBCrypto());

That's all there is to it!

Note that this middleware cannot be added in retrospect. Items not previously encrypted will cause errors when it is suddenly introduced.

Usage

You will need to provide an encryption key with every action that reads or writes items. Examples:

const options = {
    encryption: {
        key: /* your encryption key (any 24-byte Buffer) */,
    },
};

db.create(options).then((change) => {
    // ... everything else is normal
});

db.get(/* item id */).then((item) => {
    return item.getReadable(options).then((readable) => {
        // ... everything else is normal
    });
});

db.get(/* item id */).then((item) => {
    return item.getWritable(options).then((writable) => {
        // ... everything else is normal
    });
});

Encryption Algorithm

giantdb-crypto uses 192-bit AES with a per-item random initialization vector by default. The cipher is provided by Node's native crypto module, which in turn uses OpenSSL.

You can’t perform that action at this time.