Skip to main content

Secure hybrid RSA + AES encryption library with CLI

Project description

Dreamstone

Dreamstone is a modern Python library and CLI tool for secure hybrid encryption using RSA (asymmetric) + AES-GCM (symmetric). It enables you to easily generate keys, encrypt/decrypt files or base64 data, and handle encrypted payloads as JSON. Usable both as a library and CLI.


Features

  • 🔐 RSA + AES-GCM hybrid encryption
  • 🔧 Key generation with password protection (optional)
  • 📁 Encrypt/decrypt files or base64 strings
  • 🧪 Output and input in structured JSON
  • 🧰 CLI with short aliases for scripting
  • 🐍 Easily embeddable in Python apps

Installation

poetry install
poetry run dreamstone --help

For production use (once published):

pip install dreamstone

CLI Commands

Each command has long and short versions.

Command Alias Description
genkey gk Generate RSA key pair
encrypt-file enc Encrypt file or base64 string
decrypt-file dec Decrypt encrypted JSON payload

🔐 Generate RSA Key Pair

dreamstone genkey \
  --private-path private.pem \
  --public-path public.pem \
  --password "mypassword"

Arguments

Argument Alias Required Description
--private-path -pr Path to save private key
--public-path -pu Path to save public key
--password -pw Password to encrypt private key
--no-password -np Skip password protection

🔒 Encrypt File or Base64

dreamstone encrypt-file \
  --input-file secret.txt \
  --public-key-file public.pem \
  --output-file encrypted.json

Or encrypt base64 data directly:

dreamstone encrypt-file \
  --input-data "SGVsbG8gd29ybGQ=" \
  --output-file encrypted.json

Arguments

Argument Alias Required Description
--input-file -i Path to input file
--input-data -d Raw base64-encoded input data
--public-key-file -k Path to public key (auto-generated if omitted)
--output-file -o Output path for encrypted JSON
--private-key-path -pr Where to save generated private key
--public-key-path -pu Where to save generated public key
--password -pw Password for generated private key

🔓 Decrypt JSON Payload

dreamstone decrypt-file \
  encrypted.json \
  --private-key-file private.pem \
  --password "mypassword" \
  --output-file decrypted.txt

Arguments

Argument Alias Required Description
input_path - Encrypted JSON file path
--private-key-file -k RSA private key file
--password -p Password to decrypt private key
--output-file -o Output file for decrypted data

Output JSON Format

Encrypted output is stored as a JSON object:

{
  "encrypted_key": "base64...",
  "nonce": "base64...",
  "ciphertext": "base64...",
  "algorithm": "AES-GCM",
  "key_type": "RSA"
}

Python Example

from dreamstone.core.keys import generate_rsa_keypair
from dreamstone.core.encryption import encrypt
from dreamstone.core.decryption import decrypt
from dreamstone.models.payload import EncryptedPayload

# Generate keypair
priv, pub = generate_rsa_keypair()

# Encrypt
payload_dict = encrypt(b"secret", pub)
payload = EncryptedPayload(**payload_dict)

# Decrypt
decrypted = decrypt(
    encrypted_key=payload.encrypted_key,
    nonce=payload.nonce,
    ciphertext=payload.ciphertext,
    private_key=priv
)

print(decrypted.decode())  # "secret"

License

MIT License


Author

By me, Renks

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

dreamstone-0.1.3.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dreamstone-0.1.3-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file dreamstone-0.1.3.tar.gz.

File metadata

  • Download URL: dreamstone-0.1.3.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.11.2 Linux/6.1.0-37-amd64

File hashes

Hashes for dreamstone-0.1.3.tar.gz
Algorithm Hash digest
SHA256 e8540e968635c5e81d773b2fba6c715f8c783a9e15be1dfdca9810438788926f
MD5 4334343b0a2f4f956d4a24411da24951
BLAKE2b-256 7d6ef6dce4d0cc2e7015438b4d4c5bd56c3ffd5d0c8fe0b2d2125e2e62bd97c1

See more details on using hashes here.

File details

Details for the file dreamstone-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: dreamstone-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 8.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.11.2 Linux/6.1.0-37-amd64

File hashes

Hashes for dreamstone-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 7798c78c5c20686b0e4a898e447dba9d5dd70af43e23a415137be3403ca5a244
MD5 ccf704da432a349e32c69d3fa04d4c64
BLAKE2b-256 7fe26f0fee4fa725d935f88373fc713be64ae929f936534b750466302b8948e0

See more details on using hashes here.

Supported by

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