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 uv:

uv add zxtx

Or just to test it out:

uvx zxtx --help

Usage

Writing a ZXTX file

zxtx write input.txt output.zxtx --cipher 1 --compression 1 -u private_key.pem -k public_key.pem -C certificate.pem

Reading a ZXTX file

zxtx read example.zxtx output.txt -u private_key.pem -k public_key.pem -C certificate.pem --verify

Dumping metadata

zxtx dump example.zxtx -u private_key.pem -k public_key.pem -C certificate.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 1

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

# Full pipe chain: encrypt, then decrypt
cat data.txt | zxtx write - - --cipher 1 | 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

  • 0: none
  • 1: aes256_gcm
  • 2: chacha20_poly1305
  • 3: aes256_ctr_hmac

Compression Methods

  • 0: none
  • 1: zlib
  • 2: lzma
  • 3: 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-2026 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.2.tar.gz (22.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.2-py3-none-any.whl (20.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: zxtx-0.2.2.tar.gz
  • Upload date:
  • Size: 22.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.2.tar.gz
Algorithm Hash digest
SHA256 f09f43fe289651a7c7b119133c1a5654f98d81712bc807b20915d3049027ff57
MD5 e8a2c006ebdf159629a4bd823d634c3c
BLAKE2b-256 f634ef3fa0404b2ce22fbe4d63775a70df08a942745fe11c3b0f44af3a93187c

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: zxtx-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 20.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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 326569ffc4a55075a36dfe7662adb9e14cbb8750f36bb023ce6dd5f0e79080d4
MD5 ca77ae97c265456ecf2a3b89106a49e3
BLAKE2b-256 e931c468e7282795b4a37ba7ab7866fa5c30032956f19f1c99ad4123651615d8

See more details on using hashes here.

Provenance

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