Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encrytion Readme Example need a update #40

Open
AndreasHohnholt opened this issue Feb 21, 2017 · 1 comment
Open

Encrytion Readme Example need a update #40

AndreasHohnholt opened this issue Feb 21, 2017 · 1 comment

Comments

@AndreasHohnholt
Copy link
Contributor

AndreasHohnholt commented Feb 21, 2017

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;
        }
    });
@AndreasHohnholt AndreasHohnholt changed the title Encrytion Example need a update Encrytion Readme Example need a update Feb 21, 2017
@gr2m
Copy link
Collaborator

gr2m commented Feb 21, 2017

Thanks Andreas for letting us know! Could you send a pull request updating the README with your fix please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants