🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

bytekit

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Malware was recently detected in this package.

Affected versions:

3.4.13.4.2

bytekit

High-performance buffer transformation, encoding, and binary codec primitives

pipPyPI
Version
3.4.2
Weekly downloads
2
Maintainers
1

bytekit

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

Installation

pip install bytekit

Usage

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

Keywords

buffer bytes transform xor hex base64 binary codec encoding

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts