https://github.com/mersinvald/reed-solomon
Reed Solomon BCH encoder and decoder
https://github.com/mersinvald/reed-solomon
bch cpp decoder embedded encoder encryption reed-solomon
Last synced: 3 months ago
JSON representation
Reed Solomon BCH encoder and decoder
- Host: GitHub
- URL: https://github.com/mersinvald/reed-solomon
- Owner: mersinvald
- License: mit
- Created: 2015-12-29T16:07:49.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2023-12-15T22:21:56.000Z (almost 2 years ago)
- Last Synced: 2025-07-27T04:09:10.128Z (3 months ago)
- Topics: bch, cpp, decoder, embedded, encoder, encryption, reed-solomon
- Language: C++
- Size: 101 KB
- Stars: 141
- Watchers: 9
- Forks: 39
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Reed-Solomon
Reed Solomon BCH encoder and decoder library
## Overview
This RS implementation was designed for embedded purposes, so all the memory allocations performed on the stack.
If somebody wants to reimplement memory management with heap usage, 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 git@github.com:mersinvald/Reed-Solomon.git
```
## Build
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
## Usage
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 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;
```
## Regards
Huge thanks to authors of [wikiversity page about Reed-Solomon BCH](https://en.wikiversity.org/wiki/Reed–Solomon_codes_for_coders)
## Related projects
[Arduino Reed-Solomon Forward Error Correction library](https://github.com/simonyipeter/Arduino-FEC)