How To Reversibly Store Password With Python On Linux? How To Reversibly Store Password With Python On Linux? linux linux

How To Reversibly Store Password With Python On Linux?


Encrypting the passwords doesn't really buy you a whole lot more protection than storing in plaintext. Anyone capable of accessing the database probably also has full access to your webserver machines.

However, if the loss of security is acceptable, and you really need this, I'd generate a new keyfile (from a good source of random data) as part of the installation process and use this. Obviously store this key as securely as possible (locked down file permissions etc). Using a single key embedded in the source is not a good idea - there's no reason why seperate installations should have the same keys.


Try using PAM. You can make a module that automatically un-encrypts the key when the user logs in. This is internally how GNOME-Keyring works (if possible). You can even write PAM modules in Python with pam_python.


Password Safe is designed by Bruce Schneier and open source. It's for Windows, but you should be able to see what they are doing and possibly reuse it.

http://www.schneier.com/passsafe.html

http://passwordsafe.sourceforge.net/

Read this: If you type A-E-S into your code, you're doing it wrong.