crc24 from c to python

Posted by biiiiiaw on Stack Overflow See other posts from Stack Overflow or by biiiiiaw
Published on 2010-12-28T06:36:22Z Indexed on 2010/12/28 6:54 UTC
Read the original article Hit count: 170

Filed under:
|
|
|

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

© Stack Overflow or respective owner

Related posts about python

Related posts about c