能力值:
( LV5,RANK:65 )
|
-
-
2 楼
求指点
|
能力值:
( LV2,RANK:10 )
|
-
-
3 楼
http://www.21ic.com/tools/HotWC3_V1.23.html
它可以自动生成任意CRC表格或C语言源码。
|
能力值:
( LV13,RANK:437 )
|
-
-
4 楼
找到原因了吗
|
能力值:
( LV2,RANK:10 )
|
-
-
5 楼
翻译了一下,可以了,我也在研究这个,多交流:
#include <windows.h>
#include <stdio.h>
long long Crc64Long(char *instr)
{
long long CRCTable[256] = { 0 };
long long INITIALCRC = -1;
long long PLOY64REV = -7661587058870466123LL;
BOOL init = FALSE;
if (instr == NULL)
{
return 0;
}
long long crc = -1;
if (!init)
{
for (int i = 0; i < 256; i++)
{
long long part = (long long)i;
for (int j = 0; j < 8; j++)
{
if ((((int)part) & 1) != 0)
{
part = (part >> 1) ^ PLOY64REV;
}
else
{
part >>= 1;
}
}
CRCTable[i] = part;
}
init = TRUE;
}
int length = strlen(instr);
for (int k = 0; k < length; k++)
{
crc = CRCTable[(((int)crc) ^ instr[k]) & 255] ^ (crc >> 8);
}
return crc;
}
char * Crc64String(char *instr)
{
char *outstr = (char *)malloc(21*sizeof(char));
long long Crc64Val = Crc64Long(instr);
//printf("'%s' CRC64 => %lld\n", instr, Crc64Val);
if (Crc64Val > 0LL)
{
sprintf_s(outstr, 21, "%llx", Crc64Val);
}
else
{
sprintf_s(outstr, 21, "-%llx", -Crc64Val);
}
return outstr;
}
int main(int argc, char* argv[])
{
if (argc < 2)
{
printf("Usage : Crc64String [stringNeedCalc]\n");
return -1;
}
char *stringNeedCalc = argv[1];
printf("'%s' CRC64 is : %s\n", stringNeedCalc, Crc64String(stringNeedCalc));
getchar();
}
最后于 2020-2-6 18:52
被tomggx编辑
,原因: 更正代码
|
|
|