首页 > 解决方案 > 处理凭据时从内存和后备存储中删除数据?

问题描述

我正在开发一个需要使用 Python 的项目,我需要处理通过 python 应用程序传递的密码,没有一个是硬编码的。

经过一番挖掘,我发现python没有直接从内存中删除对象的方法,最好的解决方案是del <object name>通过调用垃圾收集器来使用以下内容:

import gc

# remove the reference to the object in memory
del <object>

# call the garbage collector to remove all unreferenced objects
gc.collect()

这似乎可行,但是后备存储中的内存呢,如果进程运行了很长时间,这种方法会确保后备存储中仍然没有对象吗?

这甚至可能不是 python 的问题,但我想确保我的实现是足够的。

标签: pythonsecuritypasswords

解决方案


推荐阅读