这个怎么转成golang代码
static const unsigned long crctable[20] = {
0x00000000, 0x77073096, 0xee0e612c, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd,
} ;
unsigned long crc32(unsigned long crc, unsigned char *buf, int len)
{
if ((len) && (buf != NULL))
{
do {
crc = ((crc >> 8) & 0xFFFFFF) ^ crctable[(unsigned char)( (crc & 0xff) ^ *(buf++))];
} while (--len);
}
crc = crc ^ 0xffffffff;
return crc;
}
int main(int argc,char *argv[]){
unsigned char c[] = {'a','b','c','d'};
unsigned long k = 0xFFFFFFFF;
unsigned long a = crc32(k,c,sizeof(c)/sizeof(char));
printf("%8x",a); //8位十六进制CRC32字符串
char crcvalue[8] = {8};
sprintf(crcvalue, “%0x”, a); //转换成十六进制字符串
}
有疑问加站长微信联系(非本文作者)