#codec #ecc #bch #no-std

no-std reed-solomon

支持无std环境的Reed-Solomon BCH编码器和解码器

8个版本

使用旧的Rust 2015

0.2.1 2018年1月20日
0.2.0 2017年9月2日
0.1.6 2016年10月17日

密码学 中排名 802

Download history 243/week @ 2024-03-06 214/week @ 2024-03-13 1075/week @ 2024-03-20 1522/week @ 2024-03-27 408/week @ 2024-04-03 193/week @ 2024-04-10 221/week @ 2024-04-17 266/week @ 2024-04-24 249/week @ 2024-05-01 237/week @ 2024-05-08 330/week @ 2024-05-15 384/week @ 2024-05-22 205/week @ 2024-05-29 182/week @ 2024-06-05 183/week @ 2024-06-12 165/week @ 2024-06-19

763 每月下载量
用于 37 个crates (7 直接)

MIT 许可证

51KB
985

Reed-Solomon BCH

license Build Status Crates.io Documentation

使用Rust实现的Reed-Solomon BCH编码器和解码器。这是从维基大学的Python实现移植过来的

设置

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

示例

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);
}

无运行时依赖