Coder Social home page Coder Social logo

base128's Introduction

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]))

base128's People

Contributors

dl7ad avatar rpuntaie avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.