Skip to main content

A Python library for encrypting text and sending it through Gmail from notebooks and scripts.

Project description

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

pip install crypted-mail

Quick Start

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

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

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

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.

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

crypted_mail-0.1.0.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

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

crypted_mail-0.1.0-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file crypted_mail-0.1.0.tar.gz.

File metadata

  • Download URL: crypted_mail-0.1.0.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for crypted_mail-0.1.0.tar.gz
Algorithm Hash digest
SHA256 fc741e9c166d9b745114337764798432d5d0b5b11a8d47a28c8e49d854bbb488
MD5 defabb7f8f9cccbd406a1a1c07120bcf
BLAKE2b-256 ac09d31264f0639d9ec029f7698fae58f002cfa095787ae4d036655d6711bbea

See more details on using hashes here.

File details

Details for the file crypted_mail-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: crypted_mail-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for crypted_mail-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bff61b901ee46409f813d22d2b38cf2dc81293b0983f74aa2a5eb6a6a0b724f1
MD5 a853302b6fd08257aeafca5574c5a54a
BLAKE2b-256 89d73ccf3cabde57d5fab48b35b4185d515374ef95893eeefbfc5faffea187c3

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