I have the following CRC function:
public static ushort ComputeCRC16(byte[] data)
{
ushort i, j, crc = 0;
int size = data.Length;
for (i = 0; i < size - 2; i++)
{
crc ^= (ushort)(data[i] << 8);
for (j = 0; j < 8; j++)
{
if ((crc & 0x8000) != 0) /* Test for bit 15 */
{
crc = (ushort)((crc << 1) ^ 0x1234); /* POLYNOMIAL */
}
else
{
crc <<= 1;
}
}
}
return crc;
}
I have been trying to use it to calculate a CRC16 from a file that is around 800 Kb, but it takes forever, I mean after five minutes, the value of i was still at around 2 000, and it should go up to 800 000.
Can someone give me an explanation on why it is so slow and what I can do to solve this issue ?
I'm working with Visual Studio 2015 on a i7 processor and the computer is not old nor broken.
Ko? - TheGeneral[MethodImpl(MethodImplOptions.AggressiveInlining)]to the function, it might help - zedling