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.
pip install binapyVerified import paths — ran on the pinned version, not inferred.
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`.
Update method calls from `serialize_from()` to `serialize_to()` and `parse_to()` to `parse_from()`.
Manually convert epoch timestamps back to `datetime` objects after parsing JSON data if `datetime` instances are expected.
Be aware that `isinstance(binapy_obj, bytes)` will return `True`. If strict type distinction is required, consider explicit checks or conversions.
Install the binapy library using pip: `pip install binapy`
Ensure you are importing the `BinaPy` class with correct capitalization: `from binapy import BinaPy`
Use a supported encoding, decoding, or compression format string. For example, to encode to base64: `bp.to('base64')` or decode from hex: `bp.decode_from('hex')`Ensure the data being passed to a decompression method (like `.decode_from('gzip')` or `.decode_from('deflate')`) was originally compressed using that specific algorithm and is not corrupted.Before calling `.ascii()`, ensure the `BinaPy` object has been decoded from its original character encoding (e.g., 'utf8', 'latin1') using `.decode_from('your_encoding')`. For example, `BinaPy(b'hello \xc3\xbc').decode_from('utf8').ascii()`No dependency data recorded yet.