计算字符数组的CRC32C校验和。
uint32_t KsalCrc32c(uint32_t seed, uint8_t *data, uint64_t len);
参数名 |
类型 |
描述 |
输入/输出 |
---|---|---|---|
seed |
32位整型数 |
CRC的种子。 |
输入 |
data |
字符数组 |
CRC的字符数组。 |
输入 |
len |
64位整型数 |
数组长度。 |
输入 |
crc |
32位整型数 |
CRC校验和。 |
输出 |
ksal/ksal_crc.h
1 | vi test.c
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | #include <stdio.h> #include <stdlib.h> #include <ksal/ksal_crc.h> int main(int argc, char **argv) { uint8_t buf[4096]; for (size_t i = 0; i < sizeof(buf); ++i) { buf[i] = (int8_t)i & 0xff; } uint32_t crc = KsalCrc32c(0x123, buf, sizeof(buf)); printf("crc = 0x%x\r\n", crc); return 0; } |
1 | gcc test.c -lksal -o test |
1 | ./test |
1 | crc = 0x4ee4ecc1 |