How the encrypt/decrypt sails.js specific model values works?

I'm reading on Sails attribute documentation the encrypt and decrypt functions for attributes and tested it on a random field alongside with mongodb. This worked well and encrypted the field before saving it on database. So, according to documentation i can decrypt that data with decrypt method. This saves a lot of code validations and library importing. But, i was wondering if is possible:

  1. To be able to verify without decrypt data (Like the compare function on bcrypt library)
  2. To encrypt data on a production db, then change the project (update, replace models or something similar) and then be able decrypt that.
  3. To be able to encrypt data, share the db with another sails project and be able to decrypt (or verify with something related to question 1) the encrypted data.

Upvotes: 1

Views: 770

Answers (1)

I just figured it out, seeking for related content on project. I've found an object called dataEncryptionKeys in /config/models.js file, with the corresponding documentation reference. This answers questions as it is supposed to behave as the key (or keys) for decryption. For the answer of first i think that it will be ok with the decrypt method for most use cases.

Upvotes: 2

Related Questions