Skip to main content
If called from command line, this encodes a binary file into base128.
If imported from python it provides a base128 class to do the same.

An instance of base128 can be used to convert to and from base128 encoding.

Encoding: The python package bitarray is used to insert a 0 bit every 8
bits of the data. Bitarray cares to shift the bits to make room for the
new bit. This is done in chunks.
The length in bits mod 8 can become greater than zero for chunks of size
not equal to a multiple of 7. So ``chunksize`` must be a multiple of 7.
Even if ``chunksize`` is a multiple of 7 the last chunk
likely has to be padded to reach a multiple of 8 after encoding.
The amount of padding can be expressed as a function of the original data
length mod ``chunksize`` (``modchunk``). ``modchunk`` is added as an
additional byte at the end of the encoding. To make this byte also
base128, we require ``chunksize``<=128.

If ``chars`` is provided, the resulting 7-bit numbers are
used as indices to map to entries of ``chars``.
With bytes ``chars`` the resulting chunks will be integer lists
and possibly still need to be typed to bytes for further processing::

with open('tstenc.txt','wb') as f: f.write(b'\n'.join([bytes(x) for x in encoded]))



Metadata

Release files for base128 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for base128 0.1.1
File Interpreter ABI Platform
base128-0.1.1-py3-none-any.whl Python 3 none any Details

Release files / base128-0.1.1-py3-none-any.whl

Download URL base128-0.1.1-py3-none-any.whl
Size 8.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
36453b3af0939404bd40519802b3cc2138db93b52761a0d57d87b47f29009e56
BLAKE2b-256 checksum
How to use checksums
05ae633ad839c7ac80b94b3483066e93ad4c4a2f8e201cc02f96028c93a70915
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1.1 This release

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page