Create structured binary data easily.
Project description
BitFactory
A module designed to facilitate quick and easy structured binary data creation allowing for the automatic adjustments of types such as lengths, checksums, etc of the modeled data.
Install
pip install bitfactory
Usage
An example for data strucured as follows:
- Type: Unsigned Byte
- Length: Unsigned Big-Endian Short that encompasses the Data and Checksum
- Data:
- Unsigned 32 bit Int
- Unsigned Byte
- Checksum: Unsigned Short that is calculated over the above Data portion only
def csum(data: bytes) -> int:
checksum = 0
for value in data:
checksum += value
return checksum
data = BFContainer()
data.type = BFUInt8(1)
data.body = BFLength(BFUInt16(endian=BFEndian.BIG), BFContainer())
data.body.checksumed = BFContainer()
data.body.checksumed.data = BFUInt32(0xAABBCCDD)
data.body.checksumed.data2 = BFUInt8(10)
data.body.checksum = BFCallableRef(BFUInt16(), csum, "checksumed")
assert b"\x01\x00\x07\xdd\xcc\xbb\xaa\n\x18\x03" == data.pack()
>>> print(data)
+None
| |- Unsigned Byte 0x01 : type
| +body length: 0x7
| +checksumed
| |- Unsigned Long 0xAABBCCDD : data
| |- Unsigned Byte 0x0A : data2
| +checksum value: 0x318
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bitfactory-0.2.0.tar.gz.
File metadata
- Download URL: bitfactory-0.2.0.tar.gz
- Upload date:
- Size: 13.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1decaea64cb43d91c6673554b6a84a6c264bf6870772e2f95bf573bb97b91790
|
|
| MD5 |
93853ce7ecbfe5f56cc445eed0b313a0
|
|
| BLAKE2b-256 |
cb0b7941294d4cb3e37114ae599f9a770d69aeb6249e82eeb051dd960f216d5e
|
Provenance
The following attestation bundles were made for bitfactory-0.2.0.tar.gz:
Publisher:
release.yml on bearswithsaws/bitfactory
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bitfactory-0.2.0.tar.gz -
Subject digest:
1decaea64cb43d91c6673554b6a84a6c264bf6870772e2f95bf573bb97b91790 - Sigstore transparency entry: 886895606
- Sigstore integration time:
-
Permalink:
bearswithsaws/bitfactory@8985dfda7be326cf86cc1c3e5c0e10f40d93fc95 -
Branch / Tag:
refs/tags/0.2.0 - Owner: https://github.com/bearswithsaws
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@8985dfda7be326cf86cc1c3e5c0e10f40d93fc95 -
Trigger Event:
push
-
Statement type:
File details
Details for the file bitfactory-0.2.0-py3-none-any.whl.
File metadata
- Download URL: bitfactory-0.2.0-py3-none-any.whl
- Upload date:
- Size: 14.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
560f449c5b4d49e2176a70fc39a32468154a2d74e1f38c4157ca2f3a37077ca8
|
|
| MD5 |
03b89026bdb01dec6ea2559c7c8ed784
|
|
| BLAKE2b-256 |
3997e6c729e7dafbbe1de2023c6c2a6a04fa53bb5b1b07f326bea10341367c0e
|
Provenance
The following attestation bundles were made for bitfactory-0.2.0-py3-none-any.whl:
Publisher:
release.yml on bearswithsaws/bitfactory
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bitfactory-0.2.0-py3-none-any.whl -
Subject digest:
560f449c5b4d49e2176a70fc39a32468154a2d74e1f38c4157ca2f3a37077ca8 - Sigstore transparency entry: 886895680
- Sigstore integration time:
-
Permalink:
bearswithsaws/bitfactory@8985dfda7be326cf86cc1c3e5c0e10f40d93fc95 -
Branch / Tag:
refs/tags/0.2.0 - Owner: https://github.com/bearswithsaws
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@8985dfda7be326cf86cc1c3e5c0e10f40d93fc95 -
Trigger Event:
push
-
Statement type: