ZXTX file format support.
Project description
ZXTX
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
.zxtxfiles
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
noneaes256_gcmchacha20_poly1305
Compression Methods
nonezliblzmabrotli
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1c015f7f3e7a6a8ae1f30b1c84709233e06bfb0765c784760ceb74db423d96a7
|
|
| MD5 |
d2209a7c4a6d75dc1231b1fedecfcf79
|
|
| BLAKE2b-256 |
098bfbac9152f508f0db7ba14d6880b5b1f99399030632c28c7fa4fb59740dc3
|
Provenance
The following attestation bundles were made for zxtx-0.2.1.tar.gz:
Publisher:
release.yml on voyager-2021/zxtx
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
zxtx-0.2.1.tar.gz -
Subject digest:
1c015f7f3e7a6a8ae1f30b1c84709233e06bfb0765c784760ceb74db423d96a7 - Sigstore transparency entry: 1508763146
- Sigstore integration time:
-
Permalink:
voyager-2021/zxtx@1ce698d8caa412e64c88ca14edb2bdf495c586ed -
Branch / Tag:
refs/heads/master - Owner: https://github.com/voyager-2021
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@1ce698d8caa412e64c88ca14edb2bdf495c586ed -
Trigger Event:
workflow_dispatch
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
265f81bef75c8ea88eec42d0013e26945839a926c0f76015dd645e14690fc94d
|
|
| MD5 |
261f707081ff420ae8964a5c96720cf7
|
|
| BLAKE2b-256 |
63c6d7e116bcc79f13e8a05bd521282884a12d9baed1cbd662951a6e89704c5d
|
Provenance
The following attestation bundles were made for zxtx-0.2.1-py3-none-any.whl:
Publisher:
release.yml on voyager-2021/zxtx
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
zxtx-0.2.1-py3-none-any.whl -
Subject digest:
265f81bef75c8ea88eec42d0013e26945839a926c0f76015dd645e14690fc94d - Sigstore transparency entry: 1508764510
- Sigstore integration time:
-
Permalink:
voyager-2021/zxtx@1ce698d8caa412e64c88ca14edb2bdf495c586ed -
Branch / Tag:
refs/heads/master - Owner: https://github.com/voyager-2021
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@1ce698d8caa412e64c88ca14edb2bdf495c586ed -
Trigger Event:
workflow_dispatch
-
Statement type: