Python, remove password from memory


Im storing some user raw_input as a variable in Python 2.7, the issue is that this is sensitive as it is the encryption passphrase for a cryptocurrency wallet. Therefore I want to ensure that once the Python script is completed, there is no trace of the passphase left anywhere on the system.

Where passphrase is the variable, is this at the end of the program:

del passphrase

good to utterly remove all traces?

Show source
| security   | memory   | python   | memory-management   2017-01-06 17:01 1 Answers

Answers to Python, remove password from memory ( 1 )

  1. 2017-01-06 17:01

    No del xxx or implicit deletion (leaving the current scope) may not be enough to hide the previously stored value. Note that this may crucially depend on your OS and your Python implementation.

    However I would advise not to roll your own security systems unless you really, really know what you're doing but rather search an already existing solution for whatever it is you want to do and use that. For example I'm not sure if either raw_input or input are suitable for cryptographical needs.

    You may get additional help in Information Security StackExchange.

Leave a reply to - Python, remove password from memory

◀ Go back