Skip to main content

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.

>>> rs = RSCodec(10)
>>> rs.encode([1,2,3,4])
b'\x01\x02\x03\x04,\x9d\x1c+=\xf8h\xfa\x98M'
>>> 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'

Project details


Release history Release notifications | RSS feed

This version

0.3

Download files

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

Source Distributions

reedsolo-0.3.zip (8.5 kB view details)

Uploaded Source

reedsolo-0.3.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

reedsolo-0.3.win32.exe (69.1 kB view details)

Uploaded Source

File details

Details for the file reedsolo-0.3.zip.

File metadata

  • Download URL: reedsolo-0.3.zip
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for reedsolo-0.3.zip
Algorithm Hash digest
SHA256 fc0795b16a729fb43d452bcdadda82ff90699bdc296b1cb49443570379a8222b
MD5 bfad5a13d5539746638808c927ea6f10
BLAKE2b-256 881aabcf86fe9bb1ae7147ca66645e070bde4e1f380022f301a05b7c1473293a

See more details on using hashes here.

File details

Details for the file reedsolo-0.3.tar.gz.

File metadata

  • Download URL: reedsolo-0.3.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for reedsolo-0.3.tar.gz
Algorithm Hash digest
SHA256 c11f074c1dc3eee86a7c976a7626e92e933e0b15cc0272654ad3760af0685d7f
MD5 eda400a679236abe3a78c5cc682ff1bc
BLAKE2b-256 b7fc9a92265c7e8d556d3af1fc023727707385645fa05714bb25817448d6df76

See more details on using hashes here.

File details

Details for the file reedsolo-0.3.win32.exe.

File metadata

  • Download URL: reedsolo-0.3.win32.exe
  • Upload date:
  • Size: 69.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for reedsolo-0.3.win32.exe
Algorithm Hash digest
SHA256 a0ea07f90aa5b944c2e67805d6f6bcdc2a77f05d81714a40332edbe2fb26a0c0
MD5 b9f072c982059150bbc007e823bcd08f
BLAKE2b-256 3297c570762cf5285c3102c60ea8c56e6a4c9afb26d711841dc7e52f75b27d35

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page