Skip to main content

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

Metadata

Release files for etypes 1.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for etypes 1.0.4
File Size Uploaded Provenance Actions
etypes-1.0.4.tar.gz 6.7 kB Without provenance Details for etypes-1.0.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for etypes 1.0.4
File Interpreter ABI Platform Actions
etypes-1.0.4-py3-none-any.whl Python 3 none any Details for etypes-1.0.4-py3-none-any.whl

Total release size: 14.7 kB

Release files / etypes-1.0.4.tar.gz

Download URL etypes-1.0.4.tar.gz
Size 6.7 kB
Tags Source
SHA-256 checksum
How to use checksums
2e65439ac2b169d2c24f9af80df7055625399fd96afba03c11690a110e24943d
BLAKE2b-256 checksum
How to use checksums
055958c590f874dff18dfd098c8b3c70467f8075182746b9a256dabd2165b1ed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.2 CPython/3.10.14 Linux/6.7.12-orbstack-00201-g2ddb8f197a46

Release files / etypes-1.0.4-py3-none-any.whl

Download URL etypes-1.0.4-py3-none-any.whl
Size 8.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d01dbbcaf32e74f29ff5a0496797300602ff3482c340a590e0655574041feaa6
BLAKE2b-256 checksum
How to use checksums
2f54e8656c5f11bd2d77d0d7699d7125f1ac445e0091c26a8c85438a7f34bab9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.2 CPython/3.10.14 Linux/6.7.12-orbstack-00201-g2ddb8f197a46

Security for etypes 1.0.4

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page