标题:
CRC校验源码 VC2012实现
[打印本页]
作者:
灰色幻想
时间:
2017-11-3 14:55
标题:
CRC校验源码 VC2012实现
CRC校验VC2012实现
0.png
(43.31 KB, 下载次数: 62)
下载附件
2017-11-3 17:29 上传
源程序如下:
#include<iostream>
#include<stdint.h>
using namespace std;
unsigned int CrcValueCalc(unsigned char *data,unsigned int length)
{
unsigned int crcValue=0xffff;
int i;
while(length--)
{
crcValue^=*data++;
for(i=8-1;i>=0;i--)
{
if(crcValue & 0x0001)
{
crcValue=(crcValue>>1)^0xa001;
}
else
{
crcValue=crcValue>>1;
}
}
}
return crcValue;
//printf("%d%d",crcValue);
}
void main()
{
uint8_t data[]={0x00,0x03,0x10,0x04,0x00,0x01};
//uint8_t data[]={0x00,0x03,0x0A,0x04,0x00,0x01};
//uint8_t data[]={0x00,0x03,0x10,0x04,0x00,0x04};
//uint8_t data[]={0x00,0x03,0x0A,0x04,0x00,0x04};
//uint8_t data[]={0x01,0x03,0xF0,0x0A,0x00,0x02};
uint8_t a=CrcValueCalc(data,6);
//printf("%x",a);//输出为ff
cout<<hex<<(int)a<<endl;
system("pause");
cout<<endl;
return;
}
复制代码
所有资料51hei提供下载:
计算CRC.rar
(1.71 MB, 下载次数: 13)
2017-11-3 14:54 上传
点击文件名下载附件
下载积分: 黑币 -5
作者:
wtf3505
时间:
2018-8-22 21:57
CRC很多多项式校验类型,需要把常用的都搞上啊
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1