simple-cryptor-pouch
pouchdb AES encryption using danang-id/simple-crypto-js which uses brix/crypto-js
var db = 'my_db'; db;// all done, docs should be transparently encrypted/decrypted
Details
If you replicate to another database, it will decrypt before sending it to the external one. So make sure that one also has a password set as well if you want it encrypted too.
If you need to decrypt manually see danang-id/simple-crypto-js
This only encrypts the contents of documents, not the _id
, _rev
or _deleted
.
I decided to make this plugin because calvinmetcalf/crypto-pouch does not work on react native.
This project should work on the following:
- web (with a Babel.js bundler)
- electron
- nodejs
- react native (with stockulus/pouchdb-react-native)
Save attachments are not ignored by default (
_attachments
), I would first need to make some test to really see if this is sane. At the moment I do not use attachments myself. More details.
Install
This plugin is hosted on npm:
npm i -s simple-cryptor-pouch
API
db.simplecryptor(password [, options])
Set up encryption on the database.
options.ignore
String or Array of Strings of properties that will not be encrypted.
Examples
Change password
const PouchDB = const SimpleCryptor = PouchDB const oldDBpath = './password-old.db'const newDBpath = './password-new.db' const oldDB = const newDB = oldDBnewDB PouchDB
file: examples/change-password.js
Sync encrypted remote
const PouchDB = const SimpleCryptor = PouchDB const localPath = './sync-remote.db'const remoteURL = 'http://127.0.0.1:5984' const local = const remote = remote // comment out to encrypt only the remote// local.simplecryptor('password') PouchDB