清除包含加密材料的字节或整数的内容
SecureBytes的Python项目详细描述
[![生成状态](https://travis-ci.com/VidaID/pysecbytes.svg?branch=master)](https://travis-ci.com/VidaID/pysecbytes)
##安装:
pip install SecureBytes
##使用:
当前支持清除整数、字符串和字节
from SecureBytes import clearmem, safemem
x = b’data that must be removed’
copy_of_x = x
clearmem(x)
assert(b’data’ not in copy_of_x)
仅在python3中,临时将mem分配器重写为零ram并防止分页:
- with safemem():
- x = b’data that must be removed’ del x
# x is not in ram
目前,safemem和scanmem在所有python和平台上都不受支持, 使用支持导入safemem、支持扫描mem进行检查
##警告:
- Do not try to derive from str or bytes… extra copies of your data will be made
- Clearing strings and bytes also clears all references to them
- If you choose store sensitive material in a class, and put clearmem in __del__, it will only be cleared when the last reference is freed
- “safemem” is not yet efficient (TODO), and it only prevents swapping on Windows (TODO)