Metadata-Version: 2.4
Name: crypted-mail
Version: 0.1.0
Summary: A Python library for encrypting text and sending it through Gmail from notebooks and scripts.
Author: Ali
License-Expression: MIT
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Communications :: Email
Classifier: Topic :: Security :: Cryptography
Requires-Python: >=3.11
Description-Content-Type: text/markdown
Requires-Dist: google-api-python-client>=2.169.0
Requires-Dist: google-auth>=2.39.0
Requires-Dist: google-auth-oauthlib>=1.2.2
Requires-Dist: PyNaCl>=1.5.0
Provides-Extra: dev
Requires-Dist: pytest>=8.3.5; extra == "dev"

# Crypted Mail

Crypted Mail is a Python library for encrypting text with a shared passphrase and sending the encrypted payload through Gmail from scripts or Jupyter notebooks.

## Install

```powershell
pip install crypted-mail
```

## Quick Start

```python
from crypted_mail import CryptedMailClient

client = CryptedMailClient()

# Run once to open the Google OAuth browser flow.
credentials_json = client.connect_gmail_oauth("client_secret.json")

payload = client.encrypt_with_passphrase(
    plaintext="hello secure world",
    passphrase="correct horse battery staple",
    sender_hint="alice@example.com",
    note="Use the passphrase we agreed on by phone.",
)

message_id = client.send_encrypted_email(
    sender="alice@example.com",
    recipient_email="bob@example.com",
    subject="Encrypted message",
    armored_payload=payload,
    credentials_or_token=credentials_json,
)

print(message_id)
```

## Reuse Saved Credentials

```python
from crypted_mail import CryptedMailClient

client = CryptedMailClient()

with open("gmail-token.json", "r", encoding="utf-8") as handle:
    credentials_json = handle.read()

plaintext = client.decrypt_with_passphrase(
    armored_text="cm1:...",
    passphrase="correct horse battery staple",
)
```

`connect_gmail_oauth()` returns serialized credentials JSON so you can store it wherever your notebook or script prefers.

## Development

```powershell
python -m venv .venv
.venv\Scripts\Activate.ps1
pip install -U pip build twine
pip install -e .[dev]
pytest
python -m build
python -m twine check dist/*
```

## Publish To PyPI

```powershell
python -m twine upload --repository testpypi dist/*
python -m twine upload dist/*
```

After publishing, create a fresh virtual environment, install the package from PyPI, and run the Quick Start example as a smoke test.
