Skip to main content

Tools for Binary and Text data conversion

Project description

bintexttools

Tools for Binary and ASCII data conversion.

Tools which allow you to convert Binary data to ASCII and ASCII to Binary format. They will allow you to keep printed version of data which need to be kept that way.

Features

  • Convert binary files to text format (HEX, BASE64, ASCII, DECIMAL, BINARY)
  • Convert text files back to binary format
  • Support for various output formats and delimiters
  • Command-line tools: bin2text and text2bin

Requirements

  • Python 3.14.0+
  • uv (recommended) or pip

Installation

Using uv (Recommended)

# Clone the repository
git clone <repository-url>
cd xmz-bin-text-tools

# Install the package
uv sync

# Activate the virtual environment
source .venv/bin/activate  # On Linux/Mac
# or
.venv\Scripts\activate  # On Windows

Using pip

pip install bintexttools

Project Structure

xmz-bin-text-tools/
├── pyproject.toml       # Project configuration
├── uv.lock              # Lock file for reproducible builds
├── README.md            # This file
├── LICENSE              # MIT License
├── src/                 # Source code
│   └── bintexttools/
│       ├── __init__.py
│       ├── bin2text.py  # Binary to text converter CLI
│       ├── text2bin.py  # Text to binary converter CLI
│       ├── bintextcommon/
│       │   ├── __init__.py
│       │   └── bin_text_common.py
│       └── bintexthelper/
│           ├── __init__.py
│           ├── bin_text.py
│           ├── bin2text_converter.py
│           ├── text2bin_converter.py
│           └── text_format.py
└── tests/               # Test suite
    └── __init__.py

Usage

Command Line Tools

Convert Binary to Text

bin2text -i input.bin -o output.txt -f HEX

Options:

  • -i, --binaryFilePath: Input binary file (required)
  • -o, --textFilePath: Output text file (optional, defaults to timestamp-based name)
  • -f, --format: Output format - BINARY, DECIMAL, HEX, ASCII, BASE64 (default: HEX)
  • -d, --delimiter: Data delimiter (optional)
  • -l, --lineCharacters: Number of characters per line (default: 0)
  • --showHeader: Show/add info header data (default: True)
  • -ll, --logging_level: Logging level (CRITICAL, ERROR, WARNING, INFO, DEBUG)

Convert Text to Binary

text2bin -i input.txt -o output.bin --header '{"textFile":{"format":"HEX"}}'

Options:

  • -i, --textFilePath: Input text file (required)
  • -o, --outputFilePath: Output binary file (optional, defaults to timestamp-based name)
  • --header: JSON header with format information (optional, auto-detected from file if present)
  • --renameFile/--no-renameFile: Automatically rename output file to original name from header (default: rename)
  • --skip-rename: Shortcut flag to disable renaming regardless of other options
  • --force/--no-force: Continue conversion even if validation fails (default: stop on errors)
  • -ll, --logging_level: Logging level (CRITICAL, ERROR, WARNING, INFO, DEBUG)

Python API

from bintexttools import bin2text, text2bin

# Convert binary to text
bin2text('input.bin', 'output.txt', format='HEX')

# Convert text to binary
text2bin('input.txt', 'output.bin', format='HEX')

Development

Setup Development Environment

# Install with development dependencies
uv sync --extra dev

# Run tests
uv run pytest

# Format code
uv run black src/ tests/

# Lint code
uv run ruff check src/ tests/

License

MIT License - see LICENSE file for details.

Author

Marcin Zelek (marcin.zelek@gmail.com)

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

bintexttools-0.2.0.tar.gz (54.4 kB view details)

Uploaded Source

Built Distribution

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

bintexttools-0.2.0-py3-none-any.whl (21.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: bintexttools-0.2.0.tar.gz
  • Upload date:
  • Size: 54.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for bintexttools-0.2.0.tar.gz
Algorithm Hash digest
SHA256 6bbe2f06ff3206ff457944bb165d6d062784836f991de16edc745254e2151761
MD5 96d1e54662d3adee9b5c71be2ca7e405
BLAKE2b-256 6605647e0f911526ef6c9177ac526318eb79b213171fc4a89cabf56f8b410772

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bintexttools-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 21.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for bintexttools-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2669812eeb85b8e44471a1f586040d0196e094cb14781252c199b1966a24576a
MD5 9993fbd51fc5b587f290560e6e1795fc
BLAKE2b-256 f3a3ad0e13a124c12e1cd4660ab6343e710dbb339605b5c8def088468849f6da

See more details on using hashes here.

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