Skip to main content

StructLayoutToolkitCore

stlcore is a minimal, high‑cohesion core library for bit‑accurate binary slicing. It provides the fundamental primitives (bits_get, bits_set, InfoSize) required to build struct layout analyzers, binary editors, protocol inspectors, and low‑level testing tools. Designed for clarity, correctness, and composability.

What You Can Do After Installing sltcore

sltcore provides a minimal and consistent bit-level abstraction layer for building higher‑level tools such as binary editors, protocol analyzers, and structured layout systems.

After installing the package, you can:

  • Extract arbitrary bit ranges from a bytearray using bits_get
  • Write arbitrary bit ranges into a bytearray using bits_set
  • Represent sizes and offsets uniformly with InfoSize
  • Build structured binary layouts on top of a stable bit‑operation core

Quick Examples: bits_get / bits_set

from sltcore.types import InfoSize, Info
from sltcore.bits import bits_get, bits_set

buf = bytearray(b"\x12\x34\x56\x78")

# Extract 4 bits at offset (1 byte, 0 bits)
value = bits_get(buf, InfoSize(1, 0), InfoSize(0, 4))
print(value.to_hex)  # 0x3

# Write 5 bits at offset (2 bytes, 3 bits)
bits_set(buf, InfoSize(2, 3), InfoSize(0, 5), 0b10101)
print(buf.hex()) # 12345578

sltcore.type.InfoSize

InfoSize is a type that represents offsets and sizes in a unified way. It supports addition and subtraction, and stores both byte and bit components.

  • byte: the byte component
  • bit: the bit component (0–7)

always normalized so that bit < 8

It is used for both offset and size, allowing consistent structural layout definitions.

sltcore.type.Info

Info stores an InfoSize and a raw integer value.

  • The value returned by bits_get is an Info instance
  • The value passed to bits_set is also an Info instance

This allows higher‑level code to treat extracted fields as structured units rather than plain integers.

sltcore.bits.bits_get

bits_get extracts a field from a bytearray using an offset and size, and returns an Info object.

Input:

  • bytearray buffer
  • InfoSize offset
  • InfoSize size

Output:

  • Info containing the extracted value and its size

sltcore.bits.bits_set

bits_set writes a value into a bytearray at the specified offset.

Input:

  • bytearray buffer
  • InfoSize offset
  • Info value (which includes its size)

The function masks and replaces the target bit range inside the buffer.

Documentation

For detailed usage, examples, and parameter descriptions, refer to the docstrings via:

python

  • help(sltcore.type.InfoSize)
  • help(sltcore.type.Info)
  • help(sltcore.bits.bits_get)
  • help(sltcore.bits.bits_set)

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sltcore-0.2.1.tar.gz (12.5 kB view details)

Uploaded Source

Built Distribution

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

sltcore-0.2.1-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file sltcore-0.2.1.tar.gz.

File metadata

  • Download URL: sltcore-0.2.1.tar.gz
  • Upload date:
  • Size: 12.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for sltcore-0.2.1.tar.gz
Algorithm Hash digest
SHA256 2a7a275fafe49aedfb6849f8e90d4f54430a213166389e75c5466f3efff7c9f5
MD5 ef2160ba216dc4672d495b61fce37875
BLAKE2b-256 dbb46d4deacce3b2c5255d0cd721b0527bcd4b126b9e31247ecb5785e16f372f

See more details on using hashes here.

File details

Details for the file sltcore-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: sltcore-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 6.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for sltcore-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 003ff03d00dcd5ba4239428555802472c91255027d2e8a671d22a0aaa636fe08
MD5 5cfb7ba770e4e7fec8ff49a784d204a3
BLAKE2b-256 0618b8798e2d28465b9f46012a165a61e3ccbe39fa3238289060bb0bd95370ad

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