Skip to main content

Secure hybrid RSA + AES encryption library with CLI

Project description

Dreamstone

Dreamstone is a Python library and CLI tool for asymmetric encryption using RSA and AES-GCM, enabling easy key generation, data encryption, and decryption of files or base64-encoded data.


Installation

Install with Poetry (recommended):

poetry install
poetry run dreamstone --help

Or via pip (when available):

pip install dreamstone
dreamstone --help

CLI Usage

Generate RSA key pair

dreamstone genkey --private-path private.pem --public-path public.pem

Encrypt a file

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

Encrypt base64 data and generate keys

dreamstone encrypt-file \
  --input-data "TWluaGEgbWVuc2FnZW0gc2VjcmV0YQ==" \
  --private-key-path private.pem \
  --public-key-path public.pem \
  --output-file encrypted.json

Decrypt file and print to stdout

dreamstone decrypt-file encrypted.json --private-key-file private.pem --password YOUR_PASSWORD_HERE

Decrypt file and save output

dreamstone decrypt-file encrypted.json --private-key-file private.pem --password YOUR_PASSWORD_HERE --output-file decrypted.txt

Python Usage Examples

from dreamstone.core.keys import generate_rsa_keypair, save_rsa_keypair_to_files, load_private_key, load_public_key
from dreamstone.core.encryption import encrypt, encrypt_with_auto_key
from dreamstone.core.decryption import decrypt
from dreamstone.models.payload import EncryptedPayload

# Generate RSA key pair and save to files
private_key, public_key = generate_rsa_keypair()
password = save_rsa_keypair_to_files(private_key, public_key, "private.pem", "public.pem", password=None)
print(f"Generated keys saved. Use this password to decrypt: {password}")

# Encrypt raw data with existing public key
with open("public.pem", "rb") as f:
    pub_key = load_public_key(f.read())

plaintext = b"My secret message"
enc_result = encrypt(plaintext, pub_key)
payload = EncryptedPayload(**enc_result)

# Save encrypted payload JSON
with open("encrypted.json", "w") as f:
    f.write(payload.to_json())

# Decrypt the payload with private key and password
with open("private.pem", "rb") as f:
    priv_key = load_private_key(f.read(), password=password.encode())

decrypted = decrypt(
    encrypted_key=payload.encrypted_key,
    nonce=payload.nonce,
    ciphertext=payload.ciphertext,
    private_key=priv_key,
)

print("Decrypted message:", decrypted.decode())

License

MIT License


Contact

For issues and contributions, please open an issue or pull request on the repository.

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.0.post2.tar.gz (5.3 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.0.post2-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file dreamstone-0.1.0.post2.tar.gz.

File metadata

  • Download URL: dreamstone-0.1.0.post2.tar.gz
  • Upload date:
  • Size: 5.3 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.0.post2.tar.gz
Algorithm Hash digest
SHA256 983dd901d41b8bbc30d5db842b503b33558010095ef784aa5e5bd239defdb258
MD5 d4e6515661c6f1eb241f054a84953f71
BLAKE2b-256 7dcabcdd18dff57e72d00589e17eb80d831dba284acdea675da6c53ec1234ec4

See more details on using hashes here.

File details

Details for the file dreamstone-0.1.0.post2-py3-none-any.whl.

File metadata

  • Download URL: dreamstone-0.1.0.post2-py3-none-any.whl
  • Upload date:
  • Size: 8.0 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.0.post2-py3-none-any.whl
Algorithm Hash digest
SHA256 07605fecdc85c23cbce05aac94e369ba5a343f9b43fab9cfdfd95839f9eb9cb5
MD5 c11f7d4db6d790dab24d160b9d9d4077
BLAKE2b-256 341fdaf9a6c867cafe4aa2626efa079e9610a2e09888e587f49a61a00fb0d297

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