Registry / database / sqlite-cipher

sqlite-cipher

JSON →
library0.3.6jsnpmunverified

sqlite-cipher v0.3.6 is a Node.js module for handling encrypted SQLite databases with sync and async operations. It supports opening, creating, encrypting, and decrypting databases using a wide range of encryption algorithms from OpenSSL (e.g., aes-256-ctr). The API mirrors sqlite-sync.js. It relies on Node.js crypto rather than SQLite's built-in SEE extension. Currently no active updates (last release 2017); consider using `better-sqlite3` with encryption or `sqlcipher` for production.

npm install sqlite-cipher
INSTALL
IMPORT
SIG · SQLITE-CIPHER
S
sqlite-cipher
databasejavascriptv0.3.6
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default export
const sqlite = require('sqlite-cipher');
import sqlite from 'sqlite-cipher';
This package provides a CommonJS default export; ESM import may fail with older Node versions.
connect
const sqlite = require('sqlite-cipher'); sqlite.connect('file.db','password','aes-256-ctr');
const { connect } = require('sqlite-cipher');
connect is a method on the default export, not a named export.
run
sqlite.run('CREATE TABLE ...');
sqlite.run('CREATE TABLE ...', callback);
run is synchronous; do not pass a callback as it returns results directly.

Quickstart showing connect, create table, insert, query, close, encrypt, and decrypt with sqlite-cipher.

const sqlite = require('sqlite-cipher'); const fs = require('fs'); // Connect to or create an encrypted database sqlite.connect('encrypted.db', process.env.DB_PASSWORD ?? 'defaultPass', 'aes-256-ctr'); // Create table sqlite.run("CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY, name TEXT);"); // Insert data sqlite.insert('users', { id: 1, name: 'Alice' }, (insertId) => { console.log('Inserted id:', insertId); }); // Query data const rows = sqlite.run('SELECT * FROM users'); console.log('Users:', rows); // Close connection sqlite.close(); // Encrypt an existing plaintext database sqlite.encrypt('plain.db', 'encrypted.enc', 'newPass', 'aes-256-ctr'); // Decrypt a database sqlite.decrypt('encrypted.enc', 'decrypted.db', 'newPass', 'aes-256-ctr');
Debug
Known issues
breakingRequires Node.js >=0.8.0; may not work on modern Node versions (e.g., >=14) due to deprecated crypto APIs.
fix
Use a maintained alternative like better-sqlite3 with sqlcipher or sql.js with encryption.
affects: >=0.8.0
deprecatedPackage has not been updated since 2017; last release 0.3.6. Known vulnerabilities may exist.
fix
Migrate to an actively maintained library.
affects: *
gotchaThe 'connect' function expects a password. If omitted, database may be unencrypted but still require password? Behavior untested.
fix
Always provide a password as second argument. Use process.env to store it.
affects: *
Errors
Common errors & fixes
Error: Cannot find module 'sqlite-sync'
sqlite-cipher depends on sqlite-sync, which is missing or not installed automatically.
fix
Install sqlite-sync manually: npm install sqlite-sync
TypeError: sqlite.connect is not a function
Incorrect import pattern; trying to destructure 'connect' as a named export.
fix
Use const sqlite = require('sqlite-cipher'); then sqlite.connect(...)
Upgrade
Version history
0.3.6latest on npm
Audit
Dependencies
sqlite-syncrequiredProvides core SQLite sync/async API used by sqlite-cipher
Agent activity
19 hits · last 30 days
node
14
Meta
2
OpenAI (training)
1
Resources
sqlite-cipher — npm install sqlite-cipher · libregistry