Binapy: Binary Data Manipulation

0.8.0 · active · verified Mon Apr 13

BinaPy is a Python module that simplifies binary data manipulation, offering a fluent interface for encoding, decoding, compressing, decompressing, and hashing data in various formats. It aims to provide a more human-friendly alternative to Python's standard library for these tasks. The library maintains an active release cadence, with version 0.8.0 released in January 2024.

Warnings

Install

Imports

Quickstart

Initialize a BinaPy object with string or bytes data, then chain method calls for transformations like compression (deflate) and encoding (base64url). The object can then be decoded back in reverse order of operations. BinaPy instances are subclasses of `bytes`.

from binapy import BinaPy

# Encode and compress data fluently
bp = BinaPy("Hello, World!").to("deflate").to("b64u")
print(f"Encoded and compressed: {bp}")

# Decode and decompress back
original_data = bp.decode_from("b64u").decode_from("deflate").ascii()
print(f"Decoded and decompressed: {original_data}")

# BinaPy objects are bytes subclasses
print(f"Is BinaPy instance a bytes object? {isinstance(bp, bytes)}")

view raw JSON →