Skip to main content

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

Metadata

Release files for padding-tool 1.0.4

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

Source distribution (sdist)

Source distribution for padding-tool 1.0.4
File Size Uploaded
padding_tool-1.0.4.tar.gz 4.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for padding-tool 1.0.4
File Interpreter ABI Platform
padding_tool-1.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 8.4 kB

Release files / padding_tool-1.0.4.tar.gz

Download URL padding_tool-1.0.4.tar.gz
Size 4.1 kB
Tags Source
SHA-256 checksum
How to use checksums
90bc848a2f45e0cd95704b83071d0d335b780c11ffa6f6744c2626fdc0212155
BLAKE2b-256 checksum
How to use checksums
968ed10d919e87609797e4b85c353792c1a0dc95efa7da12fe85c1f589c80f2b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / padding_tool-1.0.4-py3-none-any.whl

Download URL padding_tool-1.0.4-py3-none-any.whl
Size 4.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
baed6620947a398ac200023e1a9b5507c2eeca5420a6e126d2b974b5f34696ed
BLAKE2b-256 checksum
How to use checksums
2f320e62715a8ecccc7a05cd3e7ce083cbd84563e6f5990c7b6d21c9cd17bccb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release history Release notifications | RSS feed

This release

1.0.4 This release

2 release files

1.0.3

2 release files

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