/* War Times CRC algorithm 0.1 by Luigi Auriemma e-mail: aluigi@autistici.org web: aluigi.org This is the simple CRC algorithm used for the network data of the game War Times European Frontline http://www.lsgames.com Usage example: u_char msg[] = "\x00\x00\x00\x00" "\x0e\x27\x00\x00" "Hello, I'm a chat message\0"; *(u_int *)msg = wartimes_crc(msg, sizeof(msg) - 1); remember that when you want to send the data you must first send 4 bytes to specify the type of packet, 4 for the length of the data block and then the data. */ unsigned int wartimes_crc(unsigned char *data, unsigned int len) { int i; unsigned int crc = 0x0000007f, table[4] = { 0x0000162e, 0x000004d0, 0x00001994, 0x00002694 }; data += 8; for(i = 8; i < len; i++) { crc += table[i & 3] + *data; data++; } return(crc); }