source/D2Lang/src/D2Crc16.cpp
static constexpr unsigned short GenerateCrc(unsigned char i) {
  unsigned short crc = i;

  for (size_t bit = 0; bit < 16; ++bit) {
    if (crc & 0x8000) {
      crc = (crc << 1) ^ 0x1021;
    } else {
      crc <<= 1;
    }
  }

  return crc;
}
/**
 * Generates and returns the CRC-16 value that would be used in the
 * CRC-16 lookup table, for a given index in the lookup table.
 *
 * More information regarding the generation of the table:
 * https://en.wikipedia.org/wiki/Computation_of_cyclic_redundancy_checks#Generating_the_tables
 */
Generates and returns the CRC-16 value that would be used in the
CRC-16 lookup table, for a given index in the lookup table.


Generates and returns the CRC - 16 value that would be used in the CRC - 16 lookup table for a given index in the lookup table .
static constexpr unsigned short GenerateCrc(unsigned char i) {
  unsigned short crc = i;
  for (size_t bit = 0; bit < 16; ++bit) {
    if (crc & 0x8000) {
      crc = (crc << 1) ^ 0x1021;
    } else {
      crc <<= 1;
    }
  }
  return crc;
}
static constexpr unsigned short GenerateCrc ( unsigned char i ) { unsigned short crc = i ; for ( size_t bit = 0 ; bit < 16 ; ++ bit ) { if ( crc & 0x8000 ) { crc = ( crc << 1 ) ^ 0x1021 ; } else { crc <<= 1 ; } } return crc ; }
Generates and returns the CRC-16 value that would be used in the
 CRC-16 lookup table, for a given index in the lookup table.
Generates and returns the CRC - 16 value that would be used in the CRC - 16 lookup table for a given index in the lookup table .