Skip to content

BCH library C Python module. A fork of https://github.com/jkent/python-bchlib that extends support for Galois Field orders up to 31 and update bch.c to kernel source tree

License

Notifications You must be signed in to change notification settings

EgorKin/python-bchlib

 
 

Repository files navigation

python-bchlib Build Status

This is a python module for encoding and correcting data using BCH codes. This is a fork of https://github.com/jkent/python-bchlib that extends support for Galois Field orders up to 31 (previous implementation supported up to 15). And also update bch source code from kernel source tree.

Requirements

For Windows, python3.5 or greater required.
For Linux and MacOS, python2.7 or python3.4 or greater required.

Installing from source:

Make sure you have python-dev setup. For Windows, this means you need Visual Studio 2015.

$ git clone https://github.com/EgorKin/python-bchlib
$ cd python-bchlib
$ python3 ./setup.py build
$ python3 ./setup.py install

Module Documentation

bchlib.BCH( polynomial, t[, reverse] ) → bch

Constructor creates a BCH object with given polynomial and t bit strength, reverse is an optional boolean that flips the bit order of data. The Galois field order is automatically determined from the polynomial.

bch.encode( data[, ecc] ) → ecc

Encodes data with an optional starting ecc and returns an ecc.

bch.decode( data, ecc ) → ( bitflips, data, ecc )

Corrects data using ecc and returns a tuple.

bch.decode_inplace( data, ecc ) → bitflips

Corrects data using ecc in place, returning the number of bitflips.

bch.decode_syndromes( data, syndromes ) → ( bitflips, data )

Corrects data using a sequence of syndromes, of t*2 elements, returning a tuple.

bch.compute_even_syndromes( syndromes ) → syndromes

Computes even syndromes from odd ones. Takes and returns a sequence of t*2 elements.

bch.ecc_bytes

A readonly field; the number of bytes an ecc takes up.

bch.ecc_bits

A readonly field; the number of bits an ecc takes up.

bch.m

A readonly field; the Galois field order.

bch.n

A readonly field; the maximum codeword size in bits.

bch.syndromes

A readonly field; a tuple of syndromes after performing a correct operation.

bch.t

A readonly field; the number bit errors that can be corrected.

Usage Example

Look at test.py

About

BCH library C Python module. A fork of https://github.com/jkent/python-bchlib that extends support for Galois Field orders up to 31 and update bch.c to kernel source tree

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 89.8%
  • Python 9.3%
  • Shell 0.9%