Apache License 2.0

项目介绍

mrhooray/crc-rs 是一个托管在 GitHub 上的开源项目,主要使用 Rust 编写,采用 Apache License 2.0 许可证,目前获得 233 个 Star、53 次 Fork。

仓库全名
mrhooray/crc-rs
开源许可证
Apache License 2.0
Star 数
233
Fork 数
53
未关闭 Issue
14

README 摘要

crc Rust implementation of CRC. Usage Add crc to Cargo.toml Examples Using a well-known algorithm: Using a custom algorithm: Minimum supported Rust version (MSRV) This crate's MSRV is 1.83. At a minimum, the MSRV will be uses a lookup table with 256 entries (e.g. for u32 thats 256 4 bytes). 3. Table uses a lookup table with 16 256 entries (e.g. for u32 thats 16 256 4 bytes). Table is the default implementation, but…

完整内容见 GitHub 原始 README 或本页 。

常见问题

crc-rs 用什么语言开发?

主要使用 Rust 编写,采用 Apache License 2.0 许可证,目前有 233 个 Star。

crc-rs 可以免费商用吗?

仓库采用 Apache License 2.0 许可证,可免费使用与修改,商业使用请遵守许可证条款(例如保留版权声明与许可声明)。

如何获取 crc-rs 的源码?

可以直接克隆仓库:git clone https://github.com/mrhooray/crc-rs.git;安装与运行步骤见仓库 README。

crc-rs 最近还在维护吗?

仓库最近一次更新为 1月3日,当前有 14 个未关闭 Issue;Star 数为 233,可作为社区活跃度的参考。

关于

Rust implementation of CRC(16, 32, 64) with support of various standards

描述取自 GitHub 官方 API,中文内容由 GitRead 中文社区 编辑团队整理。

简要分析

热度分
572
价值分
178
活跃状态
活跃

语言占比

Rust

README

crc

Rust implementation of CRC.

ci Crate Docs License

Usage

Add crc to Cargo.toml

[dependencies]
crc = "3.4.0"

Examples

Using a well-known algorithm:

const X25: crc::Crc<u16> = crc::Crc::<u16>::new(&crc::CRC_16_IBM_SDLC);
assert_eq!(X25.checksum(b"123456789"), 0x906e);

Using a custom algorithm:

const CUSTOM_ALG: crc::Algorithm<u16> = crc::Algorithm {
    width: 16,
    poly: 0x8005,
    init: 0xffff,
    refin: false,
    refout: false,
    xorout: 0x0000,
    check: 0xaee7,
    residue: 0x0000
};
let crc = crc::Crc::<u16>::new(&CUSTOM_ALG);
let mut digest = crc.digest();
digest.update(b"123456789");
assert_eq!(digest.finalize(), 0xaee7);

Minimum supported Rust version (MSRV)

This crate’s MSRV is 1.83.

At a minimum, the MSRV will be <= the oldest stable release in the last 12 months. MSRV may be bumped in minor version releases.

Implementations

This crate has several pluggable implementations:

  1. NoTable doesn’t use a lookup table, and thus minimizes binary size and memory usage.
  2. Table<1> uses a lookup table with 256 entries (e.g. for u32 thats 256 * 4 bytes).
  3. Table<16> uses a lookup table with 16 * 256 entries (e.g. for u32 thats 16 * 256 * 4 bytes).

Table<1> is the default implementation, but this can be overridden by specifying I in Crc<W, I>. E.g.: Crc<u32, NoTable>, Crc<u64, Table<16>>, …

NOTE: Lookup tables will increase binary size if they’re generated at compile-time. Wrapping Crc initialization in a std::cell::OnceCell may be preferable if binary size is a concern.

Benchmark

cargo bench with AMD Ryzen 7 3800X (comparison).

Throughput (GiB/s)
Width NoTable Bytewise Slice16
8 0.113 0.585 3.11
16 0.105 0.483 3.23
32 0.111 0.516 3.30
64 0.139 0.517 2.92
82 0.091 0.438 0.623

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

评论

暂无评论