Skip to main content

Tools to read/write structures from stream of bytes

Project description

bytewirez

Tools to read/write structures from stream of bytes

WRITE

wire = Wire(from_bytes=b'')
wire.write(b'test')
wire.write_word(0x1234)
wire.write_fmt("I",0x31337)
wire.write_fmt("BBII", 1,2,33,44)
data = wire.dump()
  

READ

wire = Wire(from_bytes=b'test223333')
wire.readn(4)
wire.read_word()
wire.read_fmt("BBBB")

Hooks :

def _pre_read_hook(*a,**kw):
  n = a[0]
  print(f"I will read {n} bytes")
  return None

wire = Wire(from_bytes=b'test123')
wire.install_hook(wire.read, pre=_pre_read_hook)
wire.readn(4)

Reading structures (and debugging stuff)

wire = Wire(from_bytes=b'test112233')
r = StructureReader(wire)
r.will_read("test_string").readn(4)
r.will_read("items")
with r.start_list():
  wire.read_word()
  wire.read_dword()
 #...
 print(json.dumps(r.get_struct()))
 

Aaand the (ugly) html viewer (seriously, if anyone can make this stuff looks better ... ) Thanks to [https://github.com/lukaszblacha], the viewer is a bit less ugly

image

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

bytewirez-0.1.1.tar.gz (12.7 kB view details)

Uploaded Source

Built Distribution

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

bytewirez-0.1.1-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file bytewirez-0.1.1.tar.gz.

File metadata

  • Download URL: bytewirez-0.1.1.tar.gz
  • Upload date:
  • Size: 12.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for bytewirez-0.1.1.tar.gz
Algorithm Hash digest
SHA256 cf06c4436b18a868eccd90dffaabecd9e9ce94305021228e817eaca9a1db6673
MD5 346ace64017d19bb959801f4867c3083
BLAKE2b-256 ffb1af29069ea03a929617e01cce11710c2f175037cb529ba1fe479e6fa2caa6

See more details on using hashes here.

Provenance

The following attestation bundles were made for bytewirez-0.1.1.tar.gz:

Publisher: publish.yml on k3idii/bytewirez

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bytewirez-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: bytewirez-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 9.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for bytewirez-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0471ea501f1ba987716a52f5876b0aa0706925402d240a832f0b43a573238207
MD5 ece8f6df94a51ca7d8e95df7a3546322
BLAKE2b-256 a6933f7bfcfe08b24db8c59481b24d5b8cb2642fac93e915775cea4f02c507b6

See more details on using hashes here.

Provenance

The following attestation bundles were made for bytewirez-0.1.1-py3-none-any.whl:

Publisher: publish.yml on k3idii/bytewirez

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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