Python/keyrings: Difference between revisions

From Omnia
Jump to navigation Jump to search
(Created page with "== 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 python3 -m pip keyrings.cryptfile ~/.config/python_keyring")
 
No edit summary
Line 7: Line 7:


   python3 -m pip install keyring keyrings.alt
   python3 -m pip install keyring keyrings.alt
 
 
  python3 -m pip keyrings.cryptfile
== cryptfile ==
 
https://pypi.org/project/keyrings.cryptfile/
 
python3 -m pip keyrings.cryptfile
   ~/.config/python_keyring
   ~/.config/python_keyring
---
=== clone cryptfile install ===
<pre>
$ git clone https://github.com/frispete/keyrings.cryptfile
$ cd keyrings.cryptfile
$ pyvenv env
$ . env/bin/activate
(env) $ pip install -e .
</pre>
=== example cryptfile session ===
<pre>
(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
</pre>
<pre>
(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
</pre>
<pre>
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()
keyring.set_keyring(kr)
</pre>

Revision as of 23:14, 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()
keyring.set_keyring(kr)