62,614
社区成员
发帖
与我相关
我的任务
分享
String getCRC(byte[] arg) {
int i, accumulator, data, index;
String returnValue = new String();
accumulator = 0xffff;
for (i=0; i<arg.length; i++) {
data = arg[i];
index = (accumulator >> 8) ^ data;
accumulator = (accumulator << 8) ^ this.crcTable[index];
}
accumulator ^= 0xffff;
returnValue = Integer.toHexString(accumulator).toUpperCase();
for (i=returnValue.length(); i<4; i++)
returnValue = '0' + returnValue;
return returnValue;
}
char getCRC(int arg[])
{
int i, accumulator, data, index,n=0;//n为数组arg
string returnValue;
accumulator=-1;//0xffff=-1
for(int i=0;i<n;i++)
{
data=arg[i];
index = (accumulator >> 8) ^ data;
accumulator = (accumulator << 8) ^ this.crcTable[index];//不知道楼主这个代码是一个类里面的么?
}
accumulator ^=1;
returnValue =accumulator;//C++好像没这个函数能忽略大小写
for (i=n; i<4; i++)、、
returnValue = '0' + returnValue;
return returnValue;
}