c++ - nlohmann json:安全擦除密钥(C++)
问题描述
我正在使用nlohmann/json库来表示敏感信息。完成所需的处理后,我有兴趣安全地擦除该类型的密钥json
。
例子:
json test;
test["key1"] = "value1";
test["key2"] = "value2";
for (auto item = test.begin(); item != test.end(); ++item) {
// Processing going on here
// Let's print this information to simulate that it's "used"
// In the real application no data is printed / stored here,
// just processed.
std::cout << item.value().dump();
std::cout << item.key().dump();
// This particular key is not needed anymore here
}
// Keys are not needed here. How can I be sure
// that "key1" and "key2" are guaranteed
// not present in memory in any shape or form?
// Will this achieve my goal?
test.erase(test.begin(), test.end());
我试图实现的结果类似于使用memset_s方法或Microsoft 平台上的SecureZeroMemory可以实现的结果。
或者,可以借助std::fill算法将字符串内容替换为一些任意信息:
std::fill(string.begin(), string.end(), 0);
我的问题是,调用从内存中完全删除键的提议方法是否会出现,或者这些字符串的内容是否仍有可能存在于内存中?erase
json
解决方案
推荐阅读
- .net-core - 如何在 MS 团队机器人中安排和发送消息
- kubernetes - 错误:升级失败:错误验证“”:错误验证数据:ValidationError(Ingress.spec.rules[0].http):缺少必填字段“paths”
- excel - VBA复制粘贴突然重复粘贴
- sql-server - SQL中两个日期之间的周末日期和日期
- python-3.x - 从 Pandas 中的正则表达式中提取字符串以获取大型数据集
- php - 使用控制器(laravel)传递数据时出错
- python - 用于查找两个十六进制数据包之间的相似十六进制点的 Python 代码
- c# - Weeks() 在 FluentScheduler 中没有按预期工作
- c++ - 使用结构时访问冲突
- javascript - 天气小部件未从 API 获取 JSON 数据