Skip to main content

leo-packer

leo-packer is a lightweight Python library and CLI for packing and unpacking Leo Pack (.leopack) archives. It is designed for game engines and tools that need a simple, cross-platform archive format with support for:

  • Directory → archive packing
  • Optional Deflate compression (zlib)
  • Optional XOR-based obfuscation with a password (not cryptographic)
  • CRC32 checksums for integrity
  • Selective file extraction
  • Easy CLI with pack, unpack, and list commands

1. Introduction

Leo Pack is intended as a simple, self-contained virtual file system format for games and apps. It allows you to bundle all assets into a single file and extract them later.

Unlike .zip or .tar, .leopack has:

  • A small binary header with flags and CRCs (modeled after a C implementation).
  • Transparent optional compression per file.
  • Optional obfuscation to prevent casual inspection.
  • A clear and predictable structure, so loaders can be written in C, Go, or other languages.

2. Installation

Install from PyPI:

pip install leo-packer

For development, clone the repo and install in editable mode:

git clone https://github.com/bluesentinelsec/leo-packer.git
cd leo-packer
python3 -m venv .venv
source .venv/bin/activate
pip install -e .[dev]

3. CLI Usage

The CLI supports three commands:

Pack

leo-packer pack <input_dir> <output.leopack> [--compress] [--password PASSWORD]
  • Packs a directory into a .leopack file.
  • --compress enables zlib/Deflate per-file compression.
  • --password applies XOR stream obfuscation.

Unpack

leo-packer unpack <archive.leopack> <output_dir> [--password PASSWORD] [--file NAME ...]
  • Extracts all files by default.
  • Use --file to extract only specific entries.
  • Password is required if the archive was obfuscated.

List

leo-packer list <archive.leopack> [--password PASSWORD]
  • Lists archive contents without extracting.
  • Shows file names and uncompressed sizes.

4. Running Tests

All tests are written in pytest.

To run them locally:

make test

This will:

  • Install dev dependencies (pytest)
  • Run the full suite across all modules

Tests include:

  • CLI roundtrip
  • Compression and decompression
  • Obfuscation seed and XOR stream
  • Core pack/unpack
  • Pack reader integrity and CRCs

GitHub Actions CI runs tests automatically on Linux, macOS, and Windows for Python 3.8 and 3.11.


5. LeoPack Spec Information

Leo Pack archives use a simple binary format:

Header (0x54 bytes)

Offset Size Field Notes
0x00 8 Magic "LEOPACK\0"
0x08 4 Version Currently 1
0x0C 4 Pack flags 0x1 = obfuscated
0x10 8 TOC offset Absolute file offset
0x18 8 TOC size Bytes
0x20 8 Data offset Usually 0x54
0x28 8 Pack salt Used in password→seed derivation
0x30 16 Reserved Zeroed for now
0x50 4 Header CRC32 CRC32 of header with this field zeroed

TOC Entries

Each file is described as:

<u16 name_len>
<name bytes>
<flags: u16>
<name_len_dup: u16>
<offset: u64>
<size_uncompressed: u64>
<size_stored: u64>
<crc32_uncompressed: u32>
  • flags: per-file (0x1 = compressed)
  • offset: byte offset in archive where file data starts
  • size_uncompressed: original size
  • size_stored: compressed/obfuscated size
  • crc32_uncompressed: CRC32 over clear, uncompressed data

Data section

  • File data chunks (optionally compressed + obfuscated)
  • TOC always left in cleartext

License

  • Leo-packer is licensed under GPLv3.

Metadata

Release files for leo-packer 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for leo-packer 1.0.2
File Size Uploaded Provenance Actions
leo_packer-1.0.2.tar.gz 29.5 kB Without provenance Details for leo_packer-1.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for leo-packer 1.0.2
File Interpreter ABI Platform Actions
leo_packer-1.0.2-cp312-cp312-macosx_10_9_universal2.whl CPython 3.12 CPython 3.12 macOS 10.9+ universal2 (ARM64, x86-64) Details for leo_packer-1.0.2-cp312-cp312-macosx_10_9_universal2.whl

Total release size: 56.2 kB

Release files / leo_packer-1.0.2.tar.gz

Download URL leo_packer-1.0.2.tar.gz
Size 29.5 kB
Tags Source
SHA-256 checksum
How to use checksums
1e7baee50c21f2611e08174f2c46d6643ed5b16fae9024e8a8e12b9f3c62b13f
BLAKE2b-256 checksum
How to use checksums
97bb8373830b7ebd6286658a76aa0e91953bdb4baaef12be10bf897c44772f14
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / leo_packer-1.0.2-cp312-cp312-macosx_10_9_universal2.whl

Download URL leo_packer-1.0.2-cp312-cp312-macosx_10_9_universal2.whl
Size 26.7 kB
Tags CPython 3.12 macOS 10.9+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
76b1fcdd19f2af01b578942984ba7f98e5dc5883b88381e38f938b5eb7ff344d
BLAKE2b-256 checksum
How to use checksums
9cc0dc15334d2dbbf53fb5334b836a08cdbdbb456f5e1db2985c6a18badab2a7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Security for leo-packer 1.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page