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.1.tar.gz (21.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.1-py3-none-any.whl (19.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: zxtx-0.2.1.tar.gz
  • Upload date:
  • Size: 21.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.1.tar.gz
Algorithm Hash digest
SHA256 1c015f7f3e7a6a8ae1f30b1c84709233e06bfb0765c784760ceb74db423d96a7
MD5 d2209a7c4a6d75dc1231b1fedecfcf79
BLAKE2b-256 098bfbac9152f508f0db7ba14d6880b5b1f99399030632c28c7fa4fb59740dc3

See more details on using hashes here.

Provenance

The following attestation bundles were made for zxtx-0.2.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: zxtx-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 19.4 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 265f81bef75c8ea88eec42d0013e26945839a926c0f76015dd645e14690fc94d
MD5 261f707081ff420ae8964a5c96720cf7
BLAKE2b-256 63c6d7e116bcc79f13e8a05bd521282884a12d9baed1cbd662951a6e89704c5d

See more details on using hashes here.

Provenance

The following attestation bundles were made for zxtx-0.2.1-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