Skip to content

Encrytion Readme Example need a update #40

Description

@AndreasHohnholt

Hi,

I implement my encryption/decrytion (based on the sjcl lib) like the readme example but it does not work, because of the _revisions field.

This works for me:

localDB.transform({
        incoming: function (doc) {
          Object.keys(doc).forEach(function (field) {
            if (field !== '_id' && field !== '_rev' && field !== '_revisions') {
                //appuser is the current user logged in to the app
                var fieldValue = sjcl.encrypt(appuser.GetDBPassword(),angular.toJson(doc[field]));
                doc[field] = fieldValue;
            }
          });
          return doc;
        },
        outgoing: function (doc) {
          Object.keys(doc).forEach(function (field) {
            if (field !== '_id' && field !== '_rev' && field !== '_revisions') {
              var fieldValue = angular.fromJson(sjcl.decrypt(appuser.GetDBPassword(),doc[field]));
              doc[field] = fieldValue;
            }
          });
          return doc;
        }
    });

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions