Store and access passwords safely with python’s keyring

From
===Install it:===
====Run easy_install or pip:====
|
1 2 |
$ easy_install keyring $ pip install keyring |
====Or install from source:====
|
1 2 |
$ wget http://pypi.python.org/packages/source/k/keyring/keyring-0.2.tar.gz $ hg clone http://bitbucket.org/kang/python-keyring-lib/ |
====Use it:====
Store a password:
|
1 2 3 |
$ python >>> import keyring >>> keyring.set_password("myapp", "sventek", "krmit") |
Now quit (ctrl-d) and start over. You should be able to access the password, like this:
|
1 2 3 4 5 |
$ python >>> import keyring >>> keyring.get_password( "myapp", "sventek" ) 'krmit' >>> |
===Python keyring lib:===
Python keyring library was created as a Google Summer of Code project. The keyring lib supports Windows win32crypto, Mac OS X’s SXKeychain, KDE’s KWallet, Gnome’s keyring, and encrypted or unencrypted password files. When your application wants to store or fetch data from the keyring, it will just work.
This is exactly what I needed — but if easy mode doesn’t suite you and you want/need to make your own backend or specify a specific keyring to use, you can do that by calling set_keyring() or specifying it in a config.