#hash #crc #crc16 #crc32 #crc64

crc-any

To compute CRC values by providing the length of bits, expression, reflection, an initial value and a final xor value. It has built-in CRC-8-ATM, CRC-8-CDMA, CRC-16-IBM, CRC16-CCITT, CRC-32-IEEE, CRC-32-C, CRC-64-ISO and CRC-64-ECMA functions.

3 stable releases

1.1.1 Sep 5, 2018
1.1.0 Aug 25, 2018
1.0.0 Aug 24, 2018

#92 in Algorithms

Download history 345/week @ 2018-08-29 121/week @ 2018-09-05 86/week @ 2018-09-12 72/week @ 2018-09-19 74/week @ 2018-09-26 70/week @ 2018-10-03 59/week @ 2018-10-10 110/week @ 2018-10-17 71/week @ 2018-10-24 70/week @ 2018-10-31 93/week @ 2018-11-07 71/week @ 2018-11-14

154 downloads per month
Used in 10 crates (6 directly)

MIT license

45KB
157 lines

CRC Any

Build Status Build status

To compute CRC values by providing the length of bits, expression, reflection, an initial value and a final xor value. It has built-in CRC-8-ATM, CRC-8-CDMA, CRC-16-IBM, CRC16-CCITT, CRC-32-IEEE, CRC-32-C, CRC-64-ISO and CRC-64-ECMA functions.

Usage

You can use create_crc associated function to create a CRC instance by providing the length of bits, expression, reflection, an initial value and a final xor value. For example, if you want to compute a CRC-24 value.

extern crate crc_any;

use crc_any::CRC;

let mut crc24 = CRC::create_crc(0x0000000000864cfb, 24, 0x0000000000b704ce, 0x0000000000000000, false);

crc24.digest(b"hello");

assert_eq!([71, 245, 138].to_vec(), crc24.get_crc_vec());

To simplify the usage, there are several common versions of CRC whose computing functions are already built-in.

  • crc8(crc8atm)
  • crc8cdma
  • crc16(crc16ibm)
  • crc16ccitt(crcccitt)
  • crc32(crc32ieee, also called crc32b in mhash)
  • crc32mhash
    • mhash is a common library which has two weird versions of CRC32 called crc32 and crc32b. crc32 and crc32mhash in this module are crc32b and crc32 in mhash respectively.
  • crc32c
  • crc64(crc64ecma)
  • crc64iso

For instance,

extern crate crc_any;

use crc_any::CRC;

let mut crc64ecma = CRC::crc64ecma();

crc64ecma.digest(b"hello");

assert_eq!([236, 83, 136, 71, 154, 124, 145, 63].to_vec(), crc64ecma.get_crc_vec());

After getting a CRC value, you can still use the digest method to continue computing the next CRC values.

Crates.io

https://crates.io/crates/crc-any

Documentation

https://docs.rs/crc-any

License

MIT

No runtime deps