Git Product home page Git Product logo

node-sqlcipher's Introduction

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, on Windows, Mac and Linux.

Requirements

Windows

  • Visual Studio 2015
  • Python 2.7

Mac

  • brew install openssl

Installation

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

For Electron, use electron-rebuild or similar tool.

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, which is based on SQLite 3.15.2.

OpenSSL

SQLCipher depends on OpenSSL. When using NodeJS, OpenSSL is provided by NodeJS itself. For Electron, we need to use our own copy.

For Windows we bundle OpenSSL 1.0.2n. Pre-built libraries are used from https://slproweb.com/products/Win32OpenSSL.html.

On Mac we build against OpenSSL installed via brew, but statically link it so that end-users do not need to install it.

On Linux we dynamically link against the system OpenSSL.

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

Publishing

To publish a new version, run:

npm version minor -m "%s [publish binary]"
npm publish

Publishing of the prebuilt binaries is performed on CircleCI and AppVeyor.

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.

node-sqlcipher's People

Contributors

audriusk avatar bengotow avatar bnoordhuis avatar briangreenery avatar bwin avatar carter-thaxton avatar dpaleino avatar erisds avatar glasser avatar grumdrig avatar igorklopov avatar indutny avatar jeromew avatar kkaefer avatar kkoopa avatar lvivier avatar mithgol avatar motet-a avatar mscdex avatar orlandov avatar rkistner avatar ry avatar springmeyer avatar suhaig avatar tmcw avatar tomhughes avatar tootallnate avatar wilhelmberg avatar wrynearson avatar yhahn avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.