Skip to content

codeWhiteMonkey/node-sqlcipher

 
 

Repository files navigation

Fork of node-sqlite3, modified to use SQLCipher.

While the node-sqlite3 project does include support for compiling against sqlcipher, it requires manual work, and does not work out-of-the-box on Electron on Windows. This fork changes the default configuration to bundle SQLCipher directly, as well as OpenSSL where required.

Supported platforms

Tested on Node v8.x, and Electron 1.7.9.

Installing

yarn install "@journeyapps/sqlcipher"
# Or: npm install --save "@journeyapps/sqlcipher"

For electron, this should work with electron-rebuild.

Usage

var sqlite3 = require('@journeyapps/sqlcipher').verbose();
var db = new sqlite3.Database('test.db');

db.serialize(function() {
  db.run("PRAGMA key = 'mysecret'");
  db.run("CREATE TABLE lorem (info TEXT)");

  var stmt = db.prepare("INSERT INTO lorem VALUES (?)");
  for (var i = 0; i < 10; i++) {
      stmt.run("Ipsum " + i);
  }
  stmt.finalize();

  db.each("SELECT rowid AS id, info FROM lorem", function(err, row) {
      console.log(row.id + ": " + row.info);
  });
});

db.close();

SQLCipher

A copy of the source for SQLCipher 3.4.1 is bundled, based on SQLite 3.15.2.

On Windows, OpenSSL 1.0.2n is additionally bundled. This is specifically used for Electron builds. Pre-built libraries are used from https://slproweb.com/products/Win32OpenSSL.html.

On other platforms, OpenSSL is provided by NodeJS.

API

See the API documentation in the wiki.

Testing

mocha is required to run unit tests.

In sqlite3's directory (where its package.json resides) run the following:

npm install mocha
npm test

Acknowledgments

Most of the work in this library is from the node-sqlite3 library by MapBox.

Additionally, some of the SQLCipher-related changes are based on a fork by liubiggun.

License

node-sqlcipher is BSD licensed.

About

SQLCipher bindings for Node

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • PLpgSQL 64.4%
  • C++ 15.6%
  • JavaScript 14.8%
  • Shell 2.0%
  • Batchfile 1.2%
  • Dockerfile 1.2%
  • Other 0.8%