c++ - Calculate_CRC32 function. How do I convert it to calculating bytes and not bits -


i helping out friend of mine bit stuck , own c++ skills rusty. interest , curiosity quite picked this. shall try , explain best can. note 32 bit check.

uint32_t crc32::calculate_crc32(const uint32_t* pldata, uint32_t llength, uint32_t     previouscrc32)  {     uint32_t lcount;     const uint32_t lpolynomial = 0x04c11db7;     uint32_t lcrc = previouscrc32;     unsigned char* plcurrent = (unsigned char*) pldata;     lcrc ^= *plcurrent++;      while (llength-- != 0)      {        (lcount = 0 ; lcount < llength; lcount++)        {         if (lcrc & 1)         lcrc = (lcrc >> 8) ^ lpolynomial;            else              lcrc = lcrc >> 8;         }     }      return lcrc; } 

now ilength number of bytes packet contains. pldata packet data needs checked. is, function works. works bit bit. needs improved work byte byte. genius c++ developers out there far surpasses knowledge. ideas helpful. in advance guys.

read ross williams excellent tutorial on crcs, section 9 on "a table-driven implementation", calculates crc byte @ time instead of bit @ time. can @ more involved crc implementation in zlib, calculates 4 bytes @ time. can calculate eight bytes @ time.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -