#cryptography #ecc #bch #no-std

no-std reed-solomon

Reed-Solomon BCH encoder and decoder with support of no_std environment

8 releases

Uses old Rust 2015

0.2.1 Jan 20, 2018
0.2.0 Sep 2, 2017
0.1.6 Oct 17, 2016

#416 in Cryptography

Download history 44/week @ 2022-06-12 80/week @ 2022-06-19 52/week @ 2022-06-26 44/week @ 2022-07-03 56/week @ 2022-07-10 97/week @ 2022-07-17 62/week @ 2022-07-24 84/week @ 2022-07-31 151/week @ 2022-08-07 92/week @ 2022-08-14 105/week @ 2022-08-21 67/week @ 2022-08-28 105/week @ 2022-09-04 103/week @ 2022-09-11 83/week @ 2022-09-18 112/week @ 2022-09-25

432 downloads per month
Used in 35 crates (5 directly)

MIT license

51KB
985 lines

Reed-Solomon BCH

license Build Status Crates.io Documentation

Reed-Solomon BCH encoder and decoder implemented in Rust. This is a port of python implementation from Wikiversity

Setup

[dependencies]
reed-solomon = "0.2"
extern crate reed_solomon

Example

extern crate reed_solomon;

use reed_solomon::Encoder;
use reed_solomon::Decoder;

fn main() {
    let data = b"Hello World!";

    // Length of error correction code
    let ecc_len = 8;

    // Create encoder and decoder with 
    let enc = Encoder::new(ecc_len);
    let dec = Decoder::new(ecc_len);

    // Encode data
    let encoded = enc.encode(&data[..]);

    // Simulate some transmission errors
    let mut corrupted = *encoded;
    for i in 0..4 {
        corrupted[i] = 0x0;
    }

    // Try to recover data
    let known_erasures = [0];
    let recovered = dec.correct(&mut corrupted, Some(&known_erasures)).unwrap();

    let orig_str = std::str::from_utf8(data).unwrap();
    let recv_str = std::str::from_utf8(recovered.data()).unwrap();

    println!("message:               {:?}", orig_str);
    println!("original data:         {:?}", data);
    println!("error correction code: {:?}", encoded.ecc());
    println!("corrupted:             {:?}", corrupted);
    println!("repaired:              {:?}", recv_str);
}

No runtime deps