## ETYPES
This package allows for encrypting secret strings in python files in a human readable way using type hints.
it also supports dynamic loading of python files which contain encrypted strings, providing the password via an environment variable
## Installation
`$ pip install etypes`
or
`$ poetry add etypes`
## Example
Define a variable with the type hint DecryptedSecret
```
from etypes import DecryptedSecret
SECRET_VAR: DecryptedSecret = "some-secret-value"
```
### encrypt
To encrypt the file, run the following
`$ etypes encrypt -p PASSWORD ./path/to/python_file.py`
or
`$ etypes encrypt -pf ./path/to/password_file ./path/to/python_file.py`
results in
```
from etypes import EncryptedSecret
SECRET_VAR: EncryptedSecret = "gAAAAABmT9yA6HQOXF4BM6gvUG_ryKqrXK9BEgRY2W4lNQvDNBVbiCEOz50-viDLEMXA71upgcGgRbqvC-IAltbjE8w5MbSooJN5EV-8sVe1q3LndfBNzEg="
```
### decrypt
To decrypt the file run
`$ etypes decrypt -p PASSWORD ./path/to/python_file.py`
or
`$ etypes v -pf ./path/to/password_file ./path/to/python_file.py`
## Autoloader
To import this python file in your project and have it decrypt itself seamlessly when accessed.
You must import the AutoLoader
and configure it to accept a password via a environment variable or to look for a file at a path.
```
# app/settings/secrets.py
from etypes import EncryptedSecret, AutoLoader
SECRET_VAR: EncryptedSecret = "gAAAAABmT9yA6HQOXF4BM6gvUG_ryKqrXK9BEgRY2W4lNQvDNBVbiCEOz50-viDLEMXA71upgcGgRbqvC-IAltbjE8w5MbSooJN5EV-8sVe1q3LndfBNzEg="
AutoLoader(locals(), password_var_name="SOME_ENV_VAR_WHICH_CONTAINS_PASSWORD")
# or
AutoLoader(locals(), password_file="/path/to/your/secret_file")
```
import your settings/secrets file normally.
```
# app/main.py
from .settings import secrets
print(secrets.SECRET_VAR)
```
Run your application providing the password declaring in your AutoLoader
`$ SOME_ENV_VAR_WHICH_CONTAINS_PASSWORD="PASSWORD" ./main.py`
> TODO: Add support for the environs package
## Changelog
1.0.4
- fix ansible implementation and tests
1.0.2, 1.0.3
- doc updates
1.0.1 breaking changes but still initial 1.0 release
- rename hits EncryptedSecret and DecryptedSecret
1.0 release
- basic functionality
Raw data
{
"_id": null,
"home_page": "https://github.com/falsaform/etypes.git",
"name": "etypes",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.10",
"maintainer_email": null,
"keywords": "encrypt, secret string, secret, decrypt, env var",
"author": "Dan Brosnan",
"author_email": "dpjbrosnan@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/05/59/58c590f874dff18dfd098c8b3c70467f8075182746b9a256dabd2165b1ed/etypes-1.0.4.tar.gz",
"platform": null,
"description": "## ETYPES\n\nThis package allows for encrypting secret strings in python files in a human readable way using type hints. \nit also supports dynamic loading of python files which contain encrypted strings, providing the password via an environment variable\n \n## Installation\n\n`$ pip install etypes`\n\nor\n\n`$ poetry add etypes`\n\n## Example\nDefine a variable with the type hint DecryptedSecret\n```\nfrom etypes import DecryptedSecret\nSECRET_VAR: DecryptedSecret = \"some-secret-value\"\n```\n\n### encrypt\nTo encrypt the file, run the following\n\n`$ etypes encrypt -p PASSWORD ./path/to/python_file.py`\n\nor \n\n`$ etypes encrypt -pf ./path/to/password_file ./path/to/python_file.py`\n\nresults in \n\n```\nfrom etypes import EncryptedSecret\nSECRET_VAR: EncryptedSecret = \"gAAAAABmT9yA6HQOXF4BM6gvUG_ryKqrXK9BEgRY2W4lNQvDNBVbiCEOz50-viDLEMXA71upgcGgRbqvC-IAltbjE8w5MbSooJN5EV-8sVe1q3LndfBNzEg=\"\n```\n\n### decrypt\n\nTo decrypt the file run \n\n`$ etypes decrypt -p PASSWORD ./path/to/python_file.py`\n\nor \n\n`$ etypes v -pf ./path/to/password_file ./path/to/python_file.py`\n\n## Autoloader\n\nTo import this python file in your project and have it decrypt itself seamlessly when accessed.\n\nYou must import the AutoLoader\nand configure it to accept a password via a environment variable or to look for a file at a path.\n\n```\n# app/settings/secrets.py\n\nfrom etypes import EncryptedSecret, AutoLoader\nSECRET_VAR: EncryptedSecret = \"gAAAAABmT9yA6HQOXF4BM6gvUG_ryKqrXK9BEgRY2W4lNQvDNBVbiCEOz50-viDLEMXA71upgcGgRbqvC-IAltbjE8w5MbSooJN5EV-8sVe1q3LndfBNzEg=\"\n\nAutoLoader(locals(), password_var_name=\"SOME_ENV_VAR_WHICH_CONTAINS_PASSWORD\")\n# or\nAutoLoader(locals(), password_file=\"/path/to/your/secret_file\")\n\n```\nimport your settings/secrets file normally.\n\n```\n# app/main.py\n\nfrom .settings import secrets\nprint(secrets.SECRET_VAR)\n```\n\nRun your application providing the password declaring in your AutoLoader\n`$ SOME_ENV_VAR_WHICH_CONTAINS_PASSWORD=\"PASSWORD\" ./main.py`\n\n\n\n\n> TODO: Add support for the environs package \n\n## Changelog\n\n1.0.4\n- fix ansible implementation and tests\n\n\n1.0.2, 1.0.3\n- doc updates\n\n\n1.0.1 breaking changes but still initial 1.0 release\n- rename hits EncryptedSecret and DecryptedSecret\n\n\n1.0 release\n- basic functionality\n",
"bugtrack_url": null,
"license": null,
"summary": "A python module to store, encrypt and decrypt type hinted strings in a python file",
"version": "1.0.4",
"project_urls": {
"Homepage": "https://github.com/falsaform/etypes.git",
"Repository": "https://github.com/falsaform/etypes.git"
},
"split_keywords": [
"encrypt",
" secret string",
" secret",
" decrypt",
" env var"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "2f54e8656c5f11bd2d77d0d7699d7125f1ac445e0091c26a8c85438a7f34bab9",
"md5": "c8cc6d4756e1bbaf4a9b83d1d4636461",
"sha256": "d01dbbcaf32e74f29ff5a0496797300602ff3482c340a590e0655574041feaa6"
},
"downloads": -1,
"filename": "etypes-1.0.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "c8cc6d4756e1bbaf4a9b83d1d4636461",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.10",
"size": 7997,
"upload_time": "2024-05-25T07:24:03",
"upload_time_iso_8601": "2024-05-25T07:24:03.671322Z",
"url": "https://files.pythonhosted.org/packages/2f/54/e8656c5f11bd2d77d0d7699d7125f1ac445e0091c26a8c85438a7f34bab9/etypes-1.0.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "055958c590f874dff18dfd098c8b3c70467f8075182746b9a256dabd2165b1ed",
"md5": "dc2486fb9bef41580fdbbcc3f042940f",
"sha256": "2e65439ac2b169d2c24f9af80df7055625399fd96afba03c11690a110e24943d"
},
"downloads": -1,
"filename": "etypes-1.0.4.tar.gz",
"has_sig": false,
"md5_digest": "dc2486fb9bef41580fdbbcc3f042940f",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.10",
"size": 6704,
"upload_time": "2024-05-25T07:24:05",
"upload_time_iso_8601": "2024-05-25T07:24:05.090385Z",
"url": "https://files.pythonhosted.org/packages/05/59/58c590f874dff18dfd098c8b3c70467f8075182746b9a256dabd2165b1ed/etypes-1.0.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-05-25 07:24:05",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "falsaform",
"github_project": "etypes",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "etypes"
}