Как вычислить CRC ccitt xmodem с полиномом 1021 в C#
How to calculate CRC ccitt xmodem with polynomial 1021 in C#
Что я уже пробовал:
ushort result = Crc16Ccitt("*233050003LED"); private ushort Crc16Ccitt(string strInput) { byte[] bytes= Encoding.ASCII.GetBytes(strInput); const ushort poly = 4129; ushort[] table = new ushort[256]; ushort initialValue = 0xffff; ushort temp, a; ushort crc = initialValue; for (int i = 0; i < table.Length; ++i) { temp = 0; a = (ushort)(i << 8); for (int j = 0; j < 8; ++j) { if (((temp ^ a) & 0x8000) != 0) temp = (ushort)((temp << 1) ^ poly); else temp <<= 1; a <<= 1; } table[i] = temp; } for (int i = 0; i < bytes.Length; ++i) { crc = (ushort)((crc << 8) ^ table[((crc >> 8) ^ (0xff & bytes[i]))]); } return crc; }