Reputation: 45
I am trying to set up a system where I can have a collection of users with encrypted fields and do a search on those fields.
I have tried looking on MongoDB documentation but there is no clear route
I want to have something like this
{
fname : John,
lname : Smith,
ssn : "555-55-5555"
}
look like this
{
fname : John,
lname : Smith,
ssn : "fweiubv3b443hbv4f48h"
}
then be able to do a search like
db.users.find({ssn : "555-55-5555"})
The goal is to have a schema run and create the collection
db.createCollection("user", {
"validator": {
"$jsonSchema": {
....
});
Upvotes: 1
Views: 364
Reputation: 9795
A common strategy to solve this problem requires two fields on the model. One is a hash, the other is the result of encryption.
Taking your SSN example:
key1
.GCM
with key2
.ssn_hash
and ssn_enc
might be appropriate.key1
.ssn_hash
for the result above.ssn_enc
with key2
.Upvotes: 1