pastebin

Paste Search Dynamic
Recent pastes
byte data new byte
  1. using system;
  2.  
  3. public class Test
  4. {
  5.         public static void Main()
  6.         {
  7.                 byte[] data = new byte[] { 0x10, 0x63, 0x00, 0x4A, 0x00};
  8.                 ushort crc = 0xFFFF;
  9.                
  10.                 for (int i = 0; i < data.Length; i++)
  11.                 {
  12.                     crc ^= data[i];
  13.                
  14.                         for (int j = 0; j < 8; j++)
  15.                         {
  16.                         if ((crc & 0x0001) == 0x0001)
  17.                         {
  18.                             crc = (ushort)((crc >> 1) ^ 0xA001);
  19.                         }
  20.                         else
  21.                         {
  22.                             crc >>= 1;
  23.                         }
  24.                 }
  25.                 }
  26.                
  27.                 string crcString = crc.ToString("X4");
  28.                 Console.WriteLine("CRC-16 IBM: " + crcString);
  29.         }
  30. }
  31.  
Parsed in 0.010 seconds