Skip to main content

No project description provided

Project description

PyPI - Python Version PyPI - Downloads PyPI codecov PyPI - Wheel PyPI - License

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.

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

secured-0.1.6.tar.gz (7.0 kB view hashes)

Uploaded Source

Built Distribution

secured-0.1.6-py3-none-any.whl (8.6 kB view hashes)

Uploaded Python 3

Supported by

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