Skip to content
Reed Solomon BCH encoder and decoder
C++ CMake Makefile
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Reed Solomon BCH encoder and decoder library


This RS implementation was designed for embedded purposes, so all the memory allocations performed on the stack.
If somebody want to reimplement memory management with heap usege, pull requests are welcome

Getting the source

If you want only Reed-Solomon code, just clone repository.
If you want to get tests and examples also, do

git clone --recursive


There is no need in building RS library, cause all the implementation is in headers.
To build tests and examples simply run make in the folder with cloned repo and executables will emerge in the ./build folder


All the Reed-Solomon code is in folder include, you just need to include header rs.hpp

Template class ReedSolomon accepts two template arguments: message length and ecc length.
Simple example:

    char message[] = "Some very important message ought to be delivered";
    const int msglen = sizeof(message);
    const int ecclen = 8;
    char repaired[msglen];
    char encoded[msglen + ecclen];

    RS::ReedSolomon<msglen, ecclen> rs;

    rs.Encode(message, encoded);

    // Corrupting first 8 bytes of message (any 4 bytes can be repaired, no more)
    for(uint i = 0; i < ecclen / 2; i++) {
        encoded[i] = 'E';

    rs.Decode(encoded, repaired);

    std::cout << "Original:  " << message  << std::endl;
    std::cout << "Corrupted: " << encoded  << std::endl;
    std::cout << "Repaired:  " << repaired << std::endl;

    std::cout << ((memcmp(message, repaired, msglen) == 0) ? "SUCCESS" : "FAILURE") << std::endl;


Huge thanks to authors of wikiversity page about Reed-Solomon BCH

Related projects

Arduino Reed-Solomon Forward Error Correction library

You can’t perform that action at this time.