KeyCrypt
Have you ever found yourself needing to include sensitive information like passwords or cookies in your code? Often, as you're about to type out these confidential words, your programming instincts kick in and raise a red flag. You start to wonder, "Is it really safe to embed the password directly into the code?"
A quick search usually confirms your suspicion – it's not a recommended practice. So, what's the solution?
The solution is actually quite straightforward. Instead of hardcoding the sensitive word directly into your script, you can define it once as an environment variable with a unique name. Then, whenever you need to use it in your code, simply call the variable by its name.
After doing this for a project, I thought it could be helpful to simplify this process for both myself and others. So, I developed a simple package that does this automatically. I'll encode the sensitive word exclusively for you and securely store it. When you need to use the secret word, it will be decoded with your private key, allowing you to seamlessly integrate it into your code.
This approach adds an extra layer of security, making it more challenging for anyone, even if they have access to your environment variables, to discern your secret word easily. While your secret word isn't entirely invulnerable, this method certainly makes it more time-consuming and complex for unauthorized access.
Installation
KeyCrypt requires the following packages:
- cryptography == 41.0.1
pip install cryptography == 41.0.1
Usage
from keycrypt import get_secret, set_secret
set_secret:
at the first time you should set your secret in environment variables. so :
set_secret(name='gmail_pass' , value='your_password')
get_secret:
all the next time you can just call your password with it's name. so :
- Create a connection
set_secret(name='gmail_pass') # --> returns 'your_password'
usage sample:
Metadata
Release files for keycrypt 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| keycrypt-1.0.0.tar.gz | 4.1 kB | Without provenance | Details for keycrypt-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| keycrypt-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for keycrypt-1.0.0-py3-none-any.whl |
Total release size: 8.4 kB
Release files / keycrypt-1.0.0.tar.gz
| Download URL | keycrypt-1.0.0.tar.gz |
|---|---|
| Size | 4.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e0cb08a0ea9780eed43a0f6c8cf27a8ddefee223b73fb6e02d3822f401f1a598
|
|
BLAKE2b-256 checksum How to use checksums |
e10af47630fdf3d83b7f2a7b7aeb7f1ca3344e9c09022a421015f86d52b02143
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.3
|
Release files / keycrypt-1.0.0-py3-none-any.whl
| Download URL | keycrypt-1.0.0-py3-none-any.whl |
|---|---|
| Size | 4.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c6ef81c3a0571897d38f72c6e90d957b3f588459854bfd87fe062bf037923253
|
|
BLAKE2b-256 checksum How to use checksums |
1a028c6c0718a7547278e415b3975d8f9f94cf23f02cac50f82f5880bf95e2a0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.3
|
Security for keycrypt 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.