Secured
Secure your Python data structures and secrets with Secured. This package provides a straightforward solution for obscuring sensitive data in applications. It's specifically designed for developers who need to protect API keys, database credentials, and other critical configuration details from accidental exposure. Featuring customizable security measures, our tool allows you to control how sensitive information is represented and managed securely. It's ideal for projects that demand high data confidentiality and integrity. Please note that this provides a thin layer of protection.
Installation
To install Secured, run the following command:
pip install secured
Usage
Below are some examples on how to use Secured to protect your sensitive data:
Example 1: Basic Usage
from secured import Secure
# Protect a sensitive string
DATABASE_URL = "mysql://user:password@localhost/dbname"
secure_database_url = Secure(DATABASE_URL, "<Data Hidden>")
# Usage in code
print(secure_database_url) # Output: <Data Hidden>
Example 2: Custom Usage
from secured import Secure
# Protect an API key with a custom message
API_KEY = "12345-abcdef-67890-ghijk"
secure_api_key = Secure(API_KEY, "API Key Protected")
# Usage in code
print(secure_api_key) # Output: API Key Protected
Example 3: Config Usage
The Secured class allows you to securely read configuration files containing sensitive data. Here's how you can use it:
from secured import Secured
# Create a Secured object to read a YAML configuration file
secured = Secured('config.yaml', secure=True)
# Access configuration attributes securely
print(secured.config.name) # Using dot notation
print(secured.config["name"]) # Using dictionary-like notation
Example 4: Compose
from secured import Secured
# Define the custom secure message
message = "🔒 <Data Secured> 🔒"
# Example secured object
CONFIG_PATH = "examples/config.yaml"
DATABASE_URL = "mysql://{user}:{password}@localhost/dbname"
secure = Secured(CONFIG_PATH, secure=True, message=message)
# Usage in code
secure_database_url = secure.compose(DATABASE_URL, user="guest", password="guest_password")
print(secure_database_url) # Output: 🔒 <Data Secured> 🔒
print(secure_database_url.get_original()) # Careful! This will print the original data, do not use it.
print(secure_database_url == "mysql://guest:guest_password@localhost/dbname") # Output: True
Features
- Data Protection: Helps prevent the accidental logging or display of sensitive information.
- Customizable Representations: Set how your data is displayed when being secured.
- Ease of Use: Integrate seamlessly into existing Python applications.
Metadata
Release files for secured 0.1.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| secured-0.1.6.tar.gz | 7.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| secured-0.1.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 15.7 kB
Release files / secured-0.1.6.tar.gz
| Download URL | secured-0.1.6.tar.gz |
|---|---|
| Size | 7.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6af6476e2803856471f5724d61c3fbf97f2887fe27ed62a64e80f2d89d4664f2
|
|
BLAKE2b-256 checksum How to use checksums |
5eedfc4112cf703709e6412c5e7873384dd92adb71aaf446f9c8399e6dfe5d3c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.10.14
|
Release files / secured-0.1.6-py3-none-any.whl
| Download URL | secured-0.1.6-py3-none-any.whl |
|---|---|
| Size | 8.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
dd7360b288ce202595de8cb810eb98fb29d6020f72a9a541363a15313d6eff9e
|
|
BLAKE2b-256 checksum How to use checksums |
7ed15c8a159ae830ee1802fa63d0c419ec7120c70b2df9019ab12c5a42d87a5d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.10.14
|