This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Pure-Python Reed Solomon encoder/decoder

Project Description

A pure-python Reed Solomon encoder/decoder, based on the wonderful tutorial at wikiversity, written by “Bobmath”.

I only consolidated the code a little and added exceptions and a simple API. To my understanding, the algorithm can correct up to nsym/2 of the errors in the message, where nsym is the number of bytes in the error correction code (ECC). The code should work on pretty much any reasonable version of python (2.4-3.2), but I’m only testing on 2.6-3.2.


I claim no authorship of the code, and take no responsibility for the correctness of the algorithm. It’s way too much finite-field algebra for me :)

I’ve released this package as I needed an ECC codec for another project I’m working on, and I couldn’t find anything on the web (that still works).

The algorithm itself can handle messages up to 255 bytes, including the ECC bytes. The RSCodec class will split longer messages into chunks and encode/decode them separately; it shouldn’t make a difference from an API perspective.

>>> rs = RSCodec(10)
>>> rs.encode([1,2,3,4])
>>> rs.encode(b'hello world')
b'hello world\xed%T\xc4\xfd\xfd\x89\xf3\xa8\xaa'
>>> rs.decode(b'hello world\xed%T\xc4\xfd\xfd\x89\xf3\xa8\xaa')
b'hello world'
>>> rs.decode(b'heXlo worXd\xed%T\xc4\xfdX\x89\xf3\xa8\xaa')     # 3 errors
b'hello world'
>>> rs.decode(b'hXXXo worXd\xed%T\xc4\xfdX\x89\xf3\xa8\xaa')     # 5 errors
b'hello world'
>>> rs.decode(b'hXXXo worXd\xed%T\xc4\xfdXX\xf3\xa8\xaa')        # 6 errors - fail
Traceback (most recent call last):
ReedSolomonError: Could not locate error

>>> rs = RSCodec(12)
>>> rs.encode(b'hello world')
b'hello world?Ay\xb2\xbc\xdc\x01q\xb9\xe3\xe2='
>>> rs.decode(b'hello worXXXXy\xb2XX\x01q\xb9\xe3\xe2=')         # 6 errors - ok
b'hello world'
Release History

Release History

This version
History Node


History Node


History Node


Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
reedsolo-0.3.tar.gz (4.2 kB) Copy SHA256 Checksum SHA256 Source Aug 9, 2012
reedsolo-0.3.win32.exe (69.1 kB) Copy SHA256 Checksum SHA256 any Windows Installer Aug 9, 2012 (8.5 kB) Copy SHA256 Checksum SHA256 Source Aug 9, 2012

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting