Skip to main content

A simple CLI for slicing and splicing binary bit ranges.

Project description

bitcut

A simple CLI for slicing and assembling binary bit ranges. Aimed at embedded‑style bit‑field hacking and quick validation against datasheets.

  • Ever been annoyed with double checking if the hexadecimal value you are writing to a register actually set specifc bits you want to set?

  • Tired of decoding hex/decimals to see which bits are actually set and triple checking with a datasheet?

Look no further! Bitcut makes it easy to go from binary strings to hex and vice versa.

  • slice a value into bit ranges,
  • splice a value from ranges.

For bit‑field hacking, protocol specs and embedded.


Example Usage

Slice a value into bit ranges:

$ bitcut slice 0x42 6:4 3:0
[6:0] - b'1000010' # Full Slice
[6:4] - b'100'
[3:0] - b'0010'

Splice a value from bit ranges:

$ bitcut splice 6:4=100 3:0=0010
[6:4] - b'100'
[3:0] - b'0010'
Binary String: 01000010
Hexadecimal  : 0x42
Unsigned int : 66

See full help:

$ bitcut --help
$ bitcut slice --help
$ bitcut splice --help

Installation

From a local checkout: (PyPi install incoming)

$ pip install .

(Requires Python ≥3.10.)


Development

This repo uses uv for development

uv venv
uv sync              # installs dependencies + dev deps
uv pip install -e .

Run tests (coverage via pytest.ini):

uv run pytest

Coverage HTML report is written to htmlcov/index.html.


License

MIT

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

bitcut-0.1.0.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

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

bitcut-0.1.0-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file bitcut-0.1.0.tar.gz.

File metadata

  • Download URL: bitcut-0.1.0.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.7

File hashes

Hashes for bitcut-0.1.0.tar.gz
Algorithm Hash digest
SHA256 68c06f34d44aa24ff56cd7c8b1a812e7a2a24b6662811f72678e3693e6c3a35e
MD5 65d8941c6b056502c0cae608ec3cc725
BLAKE2b-256 917ed6fc6c273ba4589b9fd91f6bd228a9964dc1e4d8715574384e54d667a77a

See more details on using hashes here.

File details

Details for the file bitcut-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: bitcut-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.7

File hashes

Hashes for bitcut-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 225789939d9e019fa5384c724f59b3bbb565ce3e1bb74f90e5e3cda947e3a382
MD5 47561d427261a1425f6e607e072c2b8a
BLAKE2b-256 3d9cda4f2942b6a6588eaf9216b116e3766be85c0a2a382abddca510610659ff

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