【发布时间】:2019-06-14 08:37:05
【问题描述】:
我遵循了微软官方的数据加密和解密指南。我的问题是如何在数据库的数据中搜索给定的属性。例如,我想查询数据库中 FirstName 包含我输入的搜索名称的所有数据。但是 FirstName 在数据库中是加密的,因此它具有以下值:“CfDJ8GJ0pjnzz6BGph-AUfSYepqLrRxw5zqtqoh540M8wHqnnfZRuH542PMzLClloeYoQAq69kPRmUHnNdfg7J9jHc9ieIe1Vx9I_IQgt-XjUt5QE9lHknB1IKIZW6IAz_zh_w”
我可以在检索到数据后成功保护和取消保护数据,但我无法在旅途中查询数据。为了解密数据,我使用 _protector.Unprotect(),但是当我把它放在 where() 中时,它什么也不做,也没有任何错误。上面的代码由于某种原因不起作用。
var customers = await _context.Customers
.Include(x => x.CustomerInformation)
.Include(x => x.CustomerContact)
.Where(x => _protector.Unprotect(x.CustomerInformation.FirstName).Contains(name))
.ToListAsync();
【问题讨论】:
标签: asp.net-core-webapi asp.net-core-2.2