Metadata-Version: 2.4
Name: bytekit
Version: 3.4.2
Summary: High-performance buffer transformation, encoding, and binary codec primitives
Home-page: https://github.com/ikuznetsov-oss/bytekit
Author: Ivan Kuznetsov
Author-email: ikuznetsov-py@proton.me
License: MIT
Keywords: buffer bytes transform xor hex base64 binary codec encoding
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: keywords
Dynamic: license
Dynamic: license-file
Dynamic: requires-python
Dynamic: summary

# bytekit

High-performance buffer transformation, encoding, and binary codec primitives for Python.

## Installation

```bash
pip install bytekit
```

## Usage

```python
import bytekit

# XOR encoding
encoded = bytekit.xor(b'hello world', b'key')
decoded = bytekit.xor(encoded, b'key')

# Hex / Base64
hex_str = bytekit.to_hex(b'\xde\xad\xbe\xef')
raw = bytekit.from_hex('deadbeef')
b64 = bytekit.to_base64(b'binary data')

# PKCS7 padding
padded = bytekit.pad_pkcs7(b'short', block_size=16)
original = bytekit.unpad_pkcs7(padded)

# Hashing
digest = bytekit.sha256(b'message')
mac = bytekit.hmac_sha256(b'secret', b'data')

# Binary packing
packed = bytekit.write_uint32_le(0xDEADBEEF)
value = bytekit.read_uint32_le(packed)

# Utilities
chunks = bytekit.split(b'abcdefgh', 3)
rand = bytekit.random_bytes(32)
eq = bytekit.compare(a, b)  # constant-time
```

## API Reference

### Encoding
- `xor(data, key)` â€” XOR each byte with cycling key
- `to_hex(buf)` / `from_hex(str)` â€” hex encode/decode
- `to_base64(buf)` / `from_base64(str)` â€” base64
- `to_base32(buf)` / `from_base32(str)` â€” base32

### Padding
- `pad(buf, n, byte=0)` â€” right-pad to length n
- `pad_pkcs7(buf, block_size=16)` / `unpad_pkcs7(buf)`

### Hashing
- `sha256(buf)` / `sha256_hex(buf)` / `md5(buf)`
- `hmac_sha256(key, data)`
- `crc32(buf)`

### Binary
- `pack(fmt, *values)` / `unpack(fmt, buf)`
- `read_uint32_le/be(buf, offset)` / `write_uint32_le/be(value)`
- `read_uint16_le/be(buf, offset)`

### Manipulation
- `concat(*parts)` / `split(buf, n)` / `chunks(buf, size)`
- `rotate_left(buf, k)` / `rotate_right(buf, k)`
- `reverse(buf)` / `repeat(buf, n)`
- `interleave(a, b)` / `deinterleave(buf, count)`
- `mask(data, mask_byte)` / `fill(size, byte)`

### Comparison
- `compare(a, b)` â€” constant-time equality
- `bit_count(buf)` â€” popcount
- `hamming_distance(a, b)`

## License

MIT
