jwe-encryptify
jwe-encryptify is a Python package designed for secure encryption and decryption using
JSON Web Encryption (JWE), enhanced by AWS Key Management Service (KMS) and AWS Secrets Manager
integration. This package offers a straightforward solution for handling sensitive data, allowing
encrypted data exchange while securely managing encryption keys through AWS.
Table of Contents
Features
- Robust Data Encryption: Uses JSON Web Encryption (JWE) to ensure data security and integrity.
- AWS KMS Integration: Leverages AWS KMS for secure key encryption and decryption.
- AWS Secrets Manager: Efficiently manages public and private key pairs for encryption processes.
- User-Friendly API: Simplified methods for secure JSON payload encryption and decryption.
Installation
You can install the package via pip from PyPI:
pip install jwe-encryptify
Usage
- AWS Configuration: Ensure that your AWS credentials and region are set up. The package requires AWS permissions to access KMS and Secrets Manager.
- Environment Variable: Set
AWS_DEFAULT_REGIONas an environment variable or configure it in your AWS settings.
Encrypting Data using JWE
Use the encrypt method to secure JSON data with a public key stored in AWS Secrets Manager.
from jwe_crypto import encrypt
# Data to encrypt
data_to_encrypt = {"user": "John Doe", "account_id": "123456"}
# Encrypt the data
jwe_encrypted_token = encrypt(
kms_id="your-kms-key-id", # AWS KMS key ID for encryption
secret_name="your-secret-name", # AWS Secrets Manager secret name
secret_key="public-key", # Key name in the secret (public key)
api_response=data_to_encrypt # JSON data to encrypt
)
print("Encrypted JWE Token:", jwe_encrypted_token)
Encrypting Data using KMS
Use the encrypt method to secure JSON data using an AWS KMS key.
from kms_crypto import encrypt
# Data to encrypt
data_to_encrypt = {"user": "John Doe", "account_id": "123456"}
# Encrypt the data using KMS
kms_encrypted_value = encrypt(
kms_id="your-kms-key-id", # AWS KMS key ID used for encryption
plaintext=str(data_to_encrypt) # Convert the JSON data to a string
)
print("Encrypted KMS Value:", kms_encrypted_value)
Decrypting Data using JWE
Use the decrypt method to decrypt an encrypted JWE token using a private key from AWS Secrets
Manager.
from jwe_crypto import decrypt
# JWE token to decrypt
jwe_token = "your-encrypted-jwe-token"
# Decrypt the data
decrypted_data = decrypt(
kms_id="your-kms-key-id", # AWS KMS key ID
secret_name="your-secret-name", # AWS Secrets Manager secret name
secret_key="private-key", # Key name in the secret (private key)
jwe_payload=jwe_token # Encrypted JWE payload
)
print("Decrypted Data:", decrypted_data)
Decrypting Data using KMS
Use the decrypt method to decrypt an encrypted value using an AWS KMS key and encryption context.
from kms_crypto import decrypt
# Encrypted value to decrypt
encrypted_value = "your-encrypted-kms-value"
# Decrypt the data using KMS
decrypted_data = decrypt(
kms_id="your-kms-key-id", # AWS KMS key ID used for decryption
lambda_function_name="your-lambda-function-name", # Encryption context
encrypted_value=encrypted_value # Encrypted value to decrypt
)
print("Decrypted Data:", decrypted_data)
AWS Permissions
Ensure the following permissions are assigned to your AWS IAM role or user:
- KMS Permissions:
kms:Encryptkms:Decrypt
- Secrets Manager Permissions:
secretsmanager:GetSecretValue
Dependencies
The package requires the following dependencies:
jwcrypto: For JWE encoding and decoding.boto3: AWS SDK for Python.botocore: Core library used by boto3. Install all dependencies automatically via pip install jwe-encryptify.
License
This project is licensed under the MIT License.
Contributing
Contributions are welcome! Submit issues or pull requests to enhance the package. For major changes, please open a discussion first.
Authors
M Santhosh Kumar Initial work santhoshse7en@gmail.com
Metadata
Release files for jwe-encryptify 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| jwe_encryptify-0.0.3.tar.gz | 5.2 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| jwe_encryptify-0.0.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.6 kB
Release files / jwe_encryptify-0.0.3.tar.gz
| Download URL | jwe_encryptify-0.0.3.tar.gz |
|---|---|
| Size | 5.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5e65c028c59c08f9838499c4b152ee8aaaad648ce52999ad31f8c32cf2070439
|
|
BLAKE2b-256 checksum How to use checksums |
941b5a5e9f43b94e19edd0860bd118a490b9c58d6a3a7067a0a605699372697b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.13.0
|
Release files / jwe_encryptify-0.0.3-py3-none-any.whl
| Download URL | jwe_encryptify-0.0.3-py3-none-any.whl |
|---|---|
| Size | 5.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
109350a856d83ba7058407b7f41f0bac088000a0872d062461420e84af454809
|
|
BLAKE2b-256 checksum How to use checksums |
ecab09944ee3321bd3b4baaede664891668c983752ddd80e66c1ffe230b6508d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.13.0
|
Security for jwe-encryptify 0.0.3
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.