Registry / database / sqlite-cipher-updated

sqlite-cipher-updated

JSON →
library0.4.5jsnpmunverified

sqlite-cipher-updated is a Node.js module for handling encrypted SQLite databases using AES or other ciphers from Node's crypto module. Version 0.4.5 provides both synchronous and asynchronous APIs for opening, creating, encrypting, and decrypting SQLite database files. It supports a wide range of encryption algorithms (e.g., aes-256-ctr). The module wraps sqlite-sync.js for database operations and uses crypto-js for file encryption. Unlike better-sqlite3 or sqlite3 with SEE, this package implements encryption at the file level rather than native encryption extensions. It is available via npm and requires Node.js >=0.8.0.

npm install sqlite-cipher-updated
INSTALL
IMPORT
SIG · SQLITE-CIPHER-UPDA
S
sqlite-cipher-updated
databasejavascriptv0.4.5
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 (module.exports)
const sqlite = require('sqlite-cipher-updated');
import sqlite from 'sqlite-cipher-updated';
Package does not support ESM imports; use CommonJS require.
connect
sqlite.connect('file.db', 'password', 'aes-256-ctr');
sqlite.connect('file.db', 'password'); // missing algorithm is allowed but defaults to 'aes-256-cbc'
Algorithm parameter is optional; defaults to 'aes-256-cbc'. Use Node.js crypto algorithm names.
run
sqlite.run('CREATE TABLE test (id INT)');
sqlite.run('SQL', callback); // sync version does not accept callback
run() is synchronous; async operations use insert/update with callback.
encrypt
sqlite.encrypt('from.db', 'to.enc', 'password', 'aes-256-ctr');
const { encrypt } = require('sqlite-cipher-updated'); // destructuring not supported
encrypt is a property of the default export, not a named export.
decrypt
sqlite.decrypt('from.enc', 'to.db', 'password', 'aes-256-ctr');
sqlite.decrypt('from.enc', 'to.db', 'password'); // algorithm defaults to 'aes-256-cbc'
Algorithm parameter is optional; same as encrypt.

Demonstrates connecting to a new encrypted SQLite database, creating a table, inserting data asynchronously, updating synchronously, querying, and closing the connection.

const sqlite = require('sqlite-cipher-updated'); // Connect to a new encrypted database (creates file) sqlite.connect('test.db', 'mySecretPassword', 'aes-256-ctr'); // Create table sqlite.run("CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY, username TEXT);"); // Insert a row (async with callback) sqlite.insert("users", { username: "alice" }, function(insertId) { console.log('Inserted with ID:', insertId); // Update the record (sync) const modified = sqlite.update("users", { username: "bob" }, { id: insertId }); console.log('Rows modified:', modified); // Query data const rows = sqlite.run("SELECT * FROM users;"); console.log('Users:', rows); // Close connection sqlite.close(); });
Debug
Known issues
breakingEncrypted files created with old versions may not be compatible with new Node.js crypto API changes.
fix
Always test encryption/decryption with same Node.js version or use consistent algorithm.
affects: >=0.0.0
deprecatedThe 'create_function' API is deprecated and may be removed; use better-sqlite3 for custom functions if needed.
fix
Avoid using create_function; consider migrating to better-sqlite3 for advanced features.
affects: >=0.4.0
gotchaThe module uses crypto-js internally but Node.js crypto algorithm names; ensure you use lowercase names like 'aes-256-ctr'.
fix
Use algorithm strings from Node.js crypto.getCiphers().
affects: >=0.0.0
gotchaPassword is stored in memory; do not use weak passwords. The encryption is at file level, not per-page; security is as strong as the algorithm chosen.
fix
Use strong passwords and consider using AES-256-GCM for authentication.
affects: >=0.0.0
gotcharequire('sqlite-cipher-updated') returns a singleton; each connect() call overwrites the previous connection.
fix
Only connect to one database at a time; close before reconnecting.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: sqlite.connect is not a function
Wrong import: using destructuring or ES6 import syntax
fix
Use const sqlite = require('sqlite-cipher-updated'); then sqlite.connect(...)
Error: ERR_OSSL_EVP_WRONG_FINAL_BLOCK_LENGTH
Using an algorithm that requires padding (e.g., aes-256-cbc) and the encrypted file is corrupt or password wrong
fix
Ensure correct password and that the file is not truncated; try aes-256-ctr which does not require padding.
Error: ENOTFOUND getaddrinfo ENOTFOUND
Node.js version mismatch or missing native module (sqlite-sync.js relies on sqlite3 native build)
fix
Install build tools (node-gyp) or prebuild; ensure Node.js >= 0.8.0 and Python for compilation.
Error: Cannot find module 'sqlite-sync.js'
Missing dependency; npm did not install it
fix
Run npm install in your project; check node_modules contains sqlite-sync.js.
Upgrade
Version history
0.4.5latest on npm
Audit
Dependencies
sqlite-sync.jsrequiredCore SQLite operations (sync/async) are delegated to this package.
Agent activity
36 hits · last 30 days
node
30
Meta
1
Resources
sqlite-cipher-updated — npm install sqlite-cipher-updated · libregistry