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
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.2.zip
(8.6 kB
view details)
reedsolo-0.2.tar.gz
(4.3 kB
view details)
File details
Details for the file reedsolo-0.2.zip
.
File metadata
- Download URL: reedsolo-0.2.zip
- Upload date:
- Size: 8.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cef7eb63533ca3553523c35897d1e61a8d8b2a0e8c9735bc52b2116b2a65f8e1 |
|
MD5 | 8d1d0df3e7a99978ba001b3a79b7923f |
|
BLAKE2b-256 | adc3fefaa8e91e6d470bc2f2133a96c0aac5ff8c54f545b5de8eb31808e8e825 |
File details
Details for the file reedsolo-0.2.tar.gz
.
File metadata
- Download URL: reedsolo-0.2.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 397c28491f28cd31317c77e223df743846231e6d8c4c89240a01bcade328a645 |
|
MD5 | 14e3ec86c2534713729f09f6e509a93f |
|
BLAKE2b-256 | 6e15ab1133de62ccd0e67bcf54545a03964f26c8280f47290bcc87ac6c99bb29 |