xie123456789
¼‰„e: ¼Òˆ@³£¿Í
|
ˆDƬ£º
ÈçˆDÔõô°ÑcrcºÍУòž¸Ä³ÉÈýÁâfx5uÌÝÐΈDÓ‹Ëã ÒÑÖª 02 07 21 15 µÄºÍУòžÖµžé 1F BB [ ´ËÌû±»xie123456789ÔÚ2021-04-12 17:11ÖØоŽÝ‹ ] |
---|---|
|
xiongmao1212
ӛסÄãµÄ˜Ó×Ó£¬ÔÚÐÄÀïÓÀ´æ£¡
¼‰„e: ̽Ë÷½âÃÜ
|
public static byte[] CRC16(byte[] data) { int len = data.Length; if (len > 0) { ushort crc = 0xFFFF; for (int i = 0; i < len; i++) { crc = (ushort)(crc ^ (data)); for (int j = 0; j < 8; j++) { crc = (crc & 1) != 0 ? (ushort)((crc >> 1) ^ 0xA001) : (ushort)(crc >> 1); } } byte hi = (byte)((crc & 0xFF00) >> 8); //¸ßλÖà byte lo = (byte)(crc & 0x00FF); //µÍλÖà return new byte[] { hi, lo }; } return new byte[] { 0, 0 }; } ˜ÇÖ÷ÁôÑÔ£ºÕæÕ\¸ÐÖx£¡ |
---|---|
|