Skip to main content

A simple Python CLI tool to pad a binary file to a specified size using a given byte value.

Project description

Binary File Padding Tool

A simple Python CLI tool to pad a binary file to a specified size using a given byte value.

Features

  • Pads any binary file to a target size
  • Customizable padding byte value
  • Simple command-line interface
  • Version flag support

Requirements

  • Python 3.6 or higher

Install dependencies using:

pip install -r requirements.txt


Installation

Clone the repository.

git clone git@github.com:gilweis/padding-tool.git
cd padding-tool

Usage

python -m padding_tool --in INPUT_FILE --out OUTPUT_FILE --needed_size SIZE --padding_value VALUE

Arguments

Argument Description
--in Path to the input binary file
--out Path to save the padded output file
--needed_size Total desired size of the output file (in bytes)
--padding_value Byte value to use for padding (0–255)
--version Show program version and exit

Example

python -m padding_tool --in firmware.bin --out padded_firmware.bin --needed_size 4096 --padding_value 255

This command reads firmware.bin, pads it with 0xFF (255) bytes until the size is 4096 bytes, and writes the result to padded_firmware.bin.

Exit Codes

  • 0: File padded successfully
  • 1: Failed to pad the file

Error Handling

  • If the input file is larger than --needed_size, the program will raise an error and stop.
  • Ensure that --padding_value is in the valid range 0–255.

Build and Install

To build source and wheel distributions:

python -m build

If you don't have the build tool installed:

pip install build

To install the package locally:

pip install .

To upload to PyPI (optional):

pip install twine twine upload dist/*


License

MIT License

Version

1.0.3

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

padding_tool-1.0.4.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

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

padding_tool-1.0.4-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file padding_tool-1.0.4.tar.gz.

File metadata

  • Download URL: padding_tool-1.0.4.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for padding_tool-1.0.4.tar.gz
Algorithm Hash digest
SHA256 90bc848a2f45e0cd95704b83071d0d335b780c11ffa6f6744c2626fdc0212155
MD5 3ec98dc44e481d43023754038994d461
BLAKE2b-256 968ed10d919e87609797e4b85c353792c1a0dc95efa7da12fe85c1f589c80f2b

See more details on using hashes here.

File details

Details for the file padding_tool-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: padding_tool-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 4.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for padding_tool-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 baed6620947a398ac200023e1a9b5507c2eeca5420a6e126d2b974b5f34696ed
MD5 204df42893ae86a598352936b937f882
BLAKE2b-256 2f320e62715a8ecccc7a05cd3e7ce083cbd84563e6f5990c7b6d21c9cd17bccb

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