A solution for persistent environment variables.
Project description
Keyway
Persistent environment variables!
A simple solution to prevent accidentally uploading your API keys to GitHub. Functions similarly to normal environment variables, except the keys and values persist through restarts.
pip install keyway
Import with
import keyway
kw = keyway.Keyway()
Set, access, and delete keys like a dictionary.
kw["alpha"] = "an api key"
kw["bravo"] = "a setting"
kw["charlie"] = 42
kw["alpha"]
#>> "an api key"
del kw["alpha"]
Missing keys return None.
kw["alpha"]
#>> None
Keys are not stored in memory.
kw.keys()
#>> dict_keys([])
To retrieve a dictionary of all of a user's keys, use the "all" keyword. All keys are stored as text for simplicity.
kw[all]
#>> {'bravo': 'a variable', 'charlie': '42'}
To delete all of a user's keys, use the "all" keyword.
del kw[all]
kw[all]
#>> {}
-
By default, keys are stored in a sqlite database in the active environment folder
- Never upload your virtual environment to github.
- Optionally set a custom path and/or database name like:
-
kw = keyway.Keyway(path = "your/custom/path", db_name = "custom_name")
-
- You can also optionally set a user for the keyway instance:
-
kw = keyway.Keyway(user = "username")
-
- The "all" keyword can be disabled with
-
kw = keyway.Keyway(use_all = False)
-
- Keys are encrypted using fernet.
- This way, there is not a plaintext or easily accessible record of any of the keys.
- Moving the database from its original location will cause the data to become unreadable. This is by design, so that even if someone has the database file, they are unable to access the keys without knowing the original path.
- The cryptography library is the only external dependency.
-
License: MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file keyway-1.0.2.tar.gz.
File metadata
- Download URL: keyway-1.0.2.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
93065d1e7f0b38946569044b9510c539d95df7b5e7f3005bebc39d52c3424a5a
|
|
| MD5 |
17760c6d8c6e8c80ecd4e304606bf0b5
|
|
| BLAKE2b-256 |
57ec4bad05538ccd93313c976819203cc52620b3c598d8069bd6d2a6948cdab2
|
File details
Details for the file keyway-1.0.2-py3-none-any.whl.
File metadata
- Download URL: keyway-1.0.2-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6fc48bfc149ec3e56976fc832b03b9a825e05d0539b81d89ae9d589b866ee688
|
|
| MD5 |
2f6cfc7cf82971fa746a1aeb53435a13
|
|
| BLAKE2b-256 |
dded5f1b7316b1c4cd1140a28ac3ee695754b9eb4e501327090beae71732dec7
|