
Security News
New CNA Scorecard Tool Ranks CVE Data Quality Across the Ecosystem
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.
# Secure Encryption
A simple and secure encryption service for Python.
## Features
- AES-256-CTR encryption and decryption
- HMAC-SHA512 message authentication
- Secure environment variable handling for encryption and MAC keys
## Installation
Install the package using pip:
```bash
pip install secure-encryption
Before using the CryptoService
, you need to set up environment variables for the encryption and MAC keys. These keys should be base64 encoded 32-byte keys (for AES-256).
import os
import base64
# Generate random keys and encode them in base64
encryption_key = base64.b64encode(os.urandom(32)).decode('utf-8')
mac_key = base64.b64encode(os.urandom(32)).decode('utf-8')
# Set environment variables
os.environ['CRYPTO_SERVICE_KEY'] = encryption_key
os.environ['CRYPTO_SERVICE_MAC_KEY'] = mac_key
To encrypt a plaintext message:
from secure_encryption.crypto_service import CryptoService
plaintext = "This is a secret message."
encrypted_message = CryptoService.encrypt(plaintext)
print(f"Encrypted: {encrypted_message}")
To decrypt an encrypted message:
from secure_encryption.crypto_service import CryptoService
decrypted_message = CryptoService.decrypt(encrypted_message)
print(f"Decrypted: {decrypted_message}")
import os
import base64
from secure_encryption.crypto_service import CryptoService
# Generate and set keys
encryption_key = base64.b64encode(os.urandom(32)).decode('utf-8')
mac_key = base64.b64encode(os.urandom(32)).decode('utf-8')
os.environ['CRYPTO_SERVICE_KEY'] = encryption_key
os.environ['CRYPTO_SERVICE_MAC_KEY'] = mac_key
# Encrypt a message
plaintext = "This is a secret message."
encrypted_message = CryptoService.encrypt(plaintext)
print(f"Encrypted: {encrypted_message}")
# Decrypt the message
decrypted_message = CryptoService.decrypt(encrypted_message)
print(f"Decrypted: {decrypted_message}")
Unit tests are provided using the unittest
framework. To run the tests, use the following command:
python -m unittest discover tests
Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.
This project is licensed under the MIT License. See the LICENSE file for details.
This README file covers the basic usage, setup, and additional information about your `secure-encryption` package.
FAQs
A simple and secure encryption service for Python.
We found that secure-encryption demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.
Research
/Security News
Two npm packages masquerading as WhatsApp developer libraries include a kill switch that deletes all files if the phone number isn’t whitelisted.
Research
/Security News
Socket uncovered 11 malicious Go packages using obfuscated loaders to fetch and execute second-stage payloads via C2 domains.