Skip to main content

ZXTX file format support.

Project description

ZXTX

Test status

ZXTX is a secure, compressed, and verifiable file format for structured text and binary data. It supports optional encryption, compression, and cryptographic signing, making it ideal for transmitting sensitive files safely.

Built in Python. Powered by cryptography.

Features

  • AES-256-CTR + HMAC authenticated encryption
  • LZMA and Zlib compression support
  • Ed25519 and RSA signing and verification
  • Structured file format with typed headers and bodies
  • Command-line interface (CLI) for reading, writing, and inspecting .zxtx files

Installation

pip install zxtx

Or with PDM:

pdm add zxtx

Usage

Writing a ZXTX file

zxtx write input.txt output.zxtx --cipher aes256_gcm --compression zlib --private-key mykey.pem --certificate mycert.pem

Reading a ZXTX file

zxtx read example.zxtx output.txt --private-key mykey.pem --public-key pubkey.pem

Dumping metadata

zxtx dump example.zxtx --public-key pubkey.pem

Streaming (stdin/stdout)

ZXTX supports streaming via - for stdin/stdout, enabling pipe chains:

# Encrypt from stdin, write to file
echo "secret data" | zxtx write - output.zxtx --cipher aes256_gcm

# Read from file, write to stdout
zxtx read input.zxtx - > output.txt

# Full pipe chain: encrypt, then decrypt
cat data.txt | zxtx write - - --cipher aes256_gcm | zxtx read - - > decrypted.txt

Signature Verification

Verify signatures during read operations:

zxtx read signed.zxtx output.txt --verify --certificate cert.pem

Interactive Password Prompt

If a private key is password-protected and no password is provided, ZXTX will prompt interactively:

zxtx read encrypted.zxtx output.txt --private-key mykey.pem
# Prompts: Enter private key password (or press Enter for none):

Progress Bars

When writing to files in an interactive terminal, ZXTX displays progress bars:

zxtx write largefile.bin output.zxtx --compression lzma
# Shows: Writing ZXTX file [████████████] 100%

Supported Methods

Cipher Methods

  • none
  • aes256_gcm
  • chacha20_poly1305

Compression Methods

  • none
  • zlib
  • lzma
  • brotli

Format Specification

The ZXTX file format is formally documented in SPECIFICATION.md. It defines:

  • Magic header
  • Versioning
  • Field layout
  • Signature embedding, etc

Security Notes

  • ZXTX uses AEAD (authenticated encryption) to prevent tampering.
  • Private keys can be password-encrypted.
  • Signature verification ensures authenticity.
  • Don't share your private key. Use a certificate for signing and a public key for verification.

Python API

Basic File Operations

from zxtx.highlevel import open

with open("file.zxtx", password=b"secret", public_key=b"...") as f:
    data = f.read_bytes()

Streaming API

Stream data without loading entire files into memory:

from zxtx.highlevel import read_stream, write_stream, read_stdin, write_stdout

# Read from any binary stream
with open("input.zxtx", "rb") as f:
    data = read_stream(f, private_key=private_key)

# Write to any binary stream
with open("output.zxtx", "wb") as f:
    write_stream(b"secret data", f, cipher=CIPHER_METHOD.AES256_GCM, public_key=public_key)

# Convenience functions for stdin/stdout
data = read_stdin(private_key=private_key)
write_stdout(b"data", cipher=CIPHER_METHOD.AES256_GCM, public_key=public_key)

Chunked Streaming for Large Files

Process large files in chunks to minimize memory usage:

from zxtx.highlevel import read_stream_chunked, write_stream_chunked

# Stream large file with progress callback
with open("large_input.bin", "rb") as infile, open("output.zxtx", "wb") as outfile:
    def progress(current, total):
        print(f"Processed: {current}/{total} bytes")

    write_stream_chunked(
        infile, outfile,
        compression=COMPRESSION_METHOD.ZLIB,
        chunk_size=1024*1024,  # 1MB chunks
        progress_callback=progress
    )

# Read back with chunked streaming
with open("output.zxtx", "rb") as infile, open("recovered.bin", "wb") as outfile:
    read_stream_chunked(infile, outfile, private_key=private_key)

See the zxtx.highlevel module for full API details.

License

MIT License – Copyright (c) 2025 voyager-2021 (ZXTX)

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

zxtx-0.2.0.tar.gz (36.3 kB view details)

Uploaded Source

Built Distribution

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

zxtx-0.2.0-py3-none-any.whl (19.9 kB view details)

Uploaded Python 3

File details

Details for the file zxtx-0.2.0.tar.gz.

File metadata

  • Download URL: zxtx-0.2.0.tar.gz
  • Upload date:
  • Size: 36.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for zxtx-0.2.0.tar.gz
Algorithm Hash digest
SHA256 759e389c7d91bccc18d92a8baecb25d22d519d3dba9d7b008f54c3af6c53234b
MD5 5398752b707b78c45d4fc2a90092f358
BLAKE2b-256 2b3582a8455f594caf4126d1714e7cda83eacc005c8df35a9d96e44fcbdc3d61

See more details on using hashes here.

Provenance

The following attestation bundles were made for zxtx-0.2.0.tar.gz:

Publisher: release.yml on voyager-2021/zxtx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file zxtx-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: zxtx-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 19.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for zxtx-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8bb13a489f965fb6444b49bd3199ff72ab6f65d130d19da55a4441f257cd0e40
MD5 3657867c3ffa6b0617723fa657a061d5
BLAKE2b-256 46ce9ae21e1330f96e6696523d12ed9524ee39e07e53e9cca2e7866cbb6a9c4c

See more details on using hashes here.

Provenance

The following attestation bundles were made for zxtx-0.2.0-py3-none-any.whl:

Publisher: release.yml on voyager-2021/zxtx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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