Python/keyrings: Difference between revisions
< Python
No edit summary |
No edit summary |
||
| Line 59: | Line 59: | ||
kr = CryptFileKeyring() | kr = CryptFileKeyring() | ||
kr.keyring_key = getenv("KEYRING_CRYPTFILE_PASSWORD") or getpass() | kr.keyring_key = getenv("KEYRING_CRYPTFILE_PASSWORD") or getpass() | ||
kr.get_password("service", "user") | |||
</pre> | </pre> | ||
== keywords == | |||
Revision as of 23:18, 16 September 2026
keyrings
Another keyring db for other usage
sudo apt install python3-keyring python3-keyrings.alt # which also installs: python3-pycryptodome python3-secretstorage # or
python3 -m pip install keyring keyrings.alt
cryptfile
https://pypi.org/project/keyrings.cryptfile/
python3 -m pip keyrings.cryptfile ~/.config/python_keyring
---
clone cryptfile install
$ git clone https://github.com/frispete/keyrings.cryptfile $ cd keyrings.cryptfile $ pyvenv env $ . env/bin/activate (env) $ pip install -e .
example cryptfile session
(env) $ python3
Python 3.4.5 (default, Jul 03 2016, 12:57:15) [GCC] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from keyrings.cryptfile.cryptfile import CryptFileKeyring
>>> kr = CryptFileKeyring()
>>> kr.set_password("service", "user", "secret")
Please set a password for your new keyring: ******
Please confirm the password: ******
>>> ^d
(env) $ python3
Python 3.4.5 (default, Jul 03 2016, 12:57:15) [GCC] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from keyrings.cryptfile.cryptfile import CryptFileKeyring
>>> kr = CryptFileKeyring()
>>> kr.get_password("service", "user")
Please enter password for encrypted keyring: ******
'secret'
>>> ^d
from getpass import getpass
from os import getenv
from keyrings.cryptfile.cryptfile import CryptFileKeyring
kr = CryptFileKeyring()
kr.keyring_key = getenv("KEYRING_CRYPTFILE_PASSWORD") or getpass()
kr.get_password("service", "user")