Skip to main content

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

keyway-1.0.4.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

keyway-1.0.4-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file keyway-1.0.4.tar.gz.

File metadata

  • Download URL: keyway-1.0.4.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

Hashes for keyway-1.0.4.tar.gz
Algorithm Hash digest
SHA256 e7250f7fddb06612d251460a7b882861b7a48675c96b4830170c5574186e17c7
MD5 827e16912f6c9d4c58acba3be76f5eca
BLAKE2b-256 4beb713b7e020a794be6d5cc441d23e3e2f8e744461404d9ed36f809751db741

See more details on using hashes here.

File details

Details for the file keyway-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: keyway-1.0.4-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

Hashes for keyway-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 6af0d47e7165850f4f101a5e83649f19686bba0afe87917cae697971bea03ccb
MD5 7ff074a395b849abc20c1071b99c6b2f
BLAKE2b-256 2a4d1d2dca8b5183b3ffb1b94ab838c8bc6b00ba276061a23d01f3bc8379b9c9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page