static UInt32[] crcTable = {
0x0, 0x77073096, 0xee0e612c, 0x990951ba, 0x76dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,.......
}; public static UInt32 GetCRC32(byte[] bytes)
{
UInt32 crc = 0xFFFFFFFF;
for (int i = 0; i < 12; i++)
{
crc = ((crc >> 8) & 0x00FFFFFF) ^ crcTable[(crc ^ bytes[i]) & 0xFF];
}
return crc ^ 0xFFFFFFFF;
} private void button1_Click(object sender, EventArgs e)
{
byte[] bytes1= {0x02,0x00,0x01,0x31,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00};
UInt32 result = GetCRC32(bytes1);
}得到的result = 0x4e66e75f;而正确的应该是0x34aae691程序中是否有错误,烦请请各位大虾指正。
0x0, 0x77073096, 0xee0e612c, 0x990951ba, 0x76dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,.......
}; public static UInt32 GetCRC32(byte[] bytes)
{
UInt32 crc = 0xFFFFFFFF;
for (int i = 0; i < 12; i++)
{
crc = ((crc >> 8) & 0x00FFFFFF) ^ crcTable[(crc ^ bytes[i]) & 0xFF];
}
return crc ^ 0xFFFFFFFF;
} private void button1_Click(object sender, EventArgs e)
{
byte[] bytes1= {0x02,0x00,0x01,0x31,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00};
UInt32 result = GetCRC32(bytes1);
}得到的result = 0x4e66e75f;而正确的应该是0x34aae691程序中是否有错误,烦请请各位大虾指正。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货