Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 779
Scalextrix Avatar asked Jul 19 '26 06:07

Scalextrix


1 Answers

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.

like image 155
MSeifert Avatar answered Jul 21 '26 21:07

MSeifert



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!