crc24 from c to python
- by biiiiiaw
can someone please translate this code to python? i have tried and tried again, but have not managed it:
#define CRC24_INIT 0xB704CEL
#define CRC24_POLY 0x1864CFBL
typedef long crc24;
crc24 crc_octets(unsigned char *octets, size_t len)
{
crc24 crc = CRC24_INIT;
int i;
while (len--) {
crc ^= (*octets++) << 16;
for (i = 0; i < 8; i++) {
crc <<= 1;
if (crc & 0x1000000)
crc ^= CRC24_POLY;
}
}
return crc & 0xFFFFFFL;
}
i have the rotate left function (ROL24(value,bits_to_rotate_by)), which i know works since i got it from a source code of a reputable programmer, but i dont get the * and ++ on octet. i only sort of understand how ++ works in c++, and i dont know what * is at all