How to encrypt a pouchdb database

Edit: this answer originally refereed to version 1.x of crypto pouch, but is not correct for the current version (3.x), in the current version db.crypto(password) does not return a promise so the code examples updated are

db.crypto(password)
// <-- encryption set up

and

db.crypto(password);
db.put({_id: 'foo', bar: 'baz'}).then(function () {
    return db.get('foo');
}).then(function (doc) {
    console.log('decrypted', doc);
    return db.removeCrypto();
}).then(function () {
    return db.get('foo');
}).then(function (doc) {
    console.log('encrypted', doc);
})

Original answer (still valid for v1.x) follows:

so the documentation is a bit confusing (which I just cleaned up) but when you call db.crypto it wraps the database so that documents are transparently encrypted and decrypted

db.crypto(password).then(function () {
   // <-- encryption set up
})

and it will transparently encrypt documents you create and decrypt ones you read until you call

db.removeCrypto();

so if you want to test do something like

db.crypto(password).then(function () {
   return db.put({_id: 'foo', bar: 'baz'});
}).then(function () {
    return db.get('foo');
}).then(function (doc) {
    console.log('decrypted', doc);
    return db.removeCrypto();
}).then(function () {
    return db.get('foo');
}).then(function (doc) {
    console.log('encrypted', doc);
})