问题
Is it possible to encrypt certain Mongodb field for particular collection when the document is being inserted? And then decrypt it while publishing the collection?
回答1:
I'm not sure if this is overkill for your use case:
Mylar is a Meteor module which supports client-side encryption.
Mylar stores only encrypted data on the server, and decrypts data only in users' browsers. [...] Mylar allows the server to perform keyword search over encrypted documents, even if the documents are encrypted with different keys. [...] Finally, Mylar ensures that client-side application code is authentic, even if the server is malicious. Results with a prototype of Mylar built on top of the Meteor framework are promising
You didn't ask for a framework, but homebred security is often done wrong.
回答2:
We have published a new package planifica:encryption that let's you do client-side encryption of your mongo collections with ease! If follows the same principles as Mylar does (in fact it is based on the paper that Mylar is based on), but currently does not support all of Mylars features like server-side search.
On the other hand it uses far more advanced and performant encryption techniques for key generation and encryption that are more suitable for browsers. Also it does not replace or modify the meteor core, but instead is a normal package that uses hooks for all the automatic en-/decryption.
There is also a blog post to get you started here.
来源:https://stackoverflow.com/questions/26835411/encrypt-mongo-data-in-meteorjs