[英]MongoDb Field Encryption
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我试过查看 MongoDB 文档,但没有明确的路线
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": {
....
});
A common strategy to solve this problem requires two fields on the model.解决此问题的常用策略需要 model 上的两个字段。 One is a hash, the other is the result of encryption.
一个是hash,另一个是加密的结果。
Taking your SSN example:以您的 SSN 为例:
key1
.key1
获取明文 SSN 和 HMAC。GCM
with key2
.GCM
和key2
)对其进行加密。ssn_hash
and ssn_enc
might be appropriate.ssn_hash
和ssn_enc
这样的名称可能是合适的。key1
.key1
对其进行 HMAC。ssn_hash
for the result above.ssn_hash
上查找上述结果。ssn_enc
with key2
.key2
解密ssn_enc
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.