Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Storing passwords with python

I have a program I'm writing in python, and I have the need to store some passwords. These passwords will be the passwords to ftp servers, so it's important that they're not just plainly visible to everybody. This also means that I can't store a non-reversible hash of the password like you would on a webserver, because I'm not checking if somebody inputs the right password, I'm just relaying the password to somebody else.
So what's the best way to store passwords? I'm using python, and the program will be linux-only.

like image 1000
Carnberry Avatar asked Sep 11 '10 15:09

Carnberry


2 Answers

You could use the system's key ring, e.g. GNOME key ring or KDE wallet.

There's a Python module called keyring that supports multiple key ring providers. I have only tried it on Windows, where it doesn't yet work correctly. Seems like development isn't very active, but you should give it a try. You can also try the package "python-gnomekeyring" which is specific to GNOME and more low-level.

like image 73
AndiDog Avatar answered Oct 23 '22 15:10

AndiDog


Depending on the distribution you can probably store it in the keychain if one is available.

Otherwise take a look at some of the encryption algorithms available (PGP/GPG, DES, AES etc) and their Python ports/modules but this is hard stuff which you have to get right.

like image 41
supakeen Avatar answered Oct 23 '22 13:10

supakeen