国产免费AV|泡泡玛特欧洲总部将设在伦敦|中文天堂网www新版资源在线|一本久道综合在线中文|国精产品一二三产区的使用方法|香蕉鱼在线观看|www.27eee
ELEOK
標題:
CRC校驗源碼 VC++2012實現
[打印本頁]
作者:
coolice
時間:
2020-5-3 16:29
標題:
CRC校驗源碼 VC++2012實現
源程序如下:
VC _計算CRC.rar
(1.71 MB, 售價: 1 E幣)
2020-5-3 16:29 上傳
點擊文件名下載附件
售價: 1 E幣
[記錄]
[
購買
]
1.png
(4.5 KB)
下載附件
2020-5-3 16: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;
}
復制代碼
歡迎光臨 ELEOK (http://m.afoofa.cn/)
Powered by Discuz! X5.0