crc32

CRC32 Calculation for Zero Filled Buffer/File

家住魔仙堡 提交于 2019-12-22 15:11:14
问题 If I want to calculate the CRC32 value for a large number of consecutive zero bytes, is there a constant time formula I can use given the length of the run of zeros? For example, if I know I have 1000 bytes all filled with zeros, is there a way to avoid a loop with 1000 iterations (just an example, actual number of zeros is unbounded for the sake of this question)? 回答1: You can compute the result of applying n zeros not in O(1) time, but in O(log n ) time. This is done in zlib's crc32_combine

Calculate/validate bz2 (bzip2) CRC32 in Python

爷,独闯天下 提交于 2019-12-21 12:46:07
问题 I'm trying to calculate/validate the CRC32 checksums for compressed bzip2 archives. .magic:16 = 'BZ' signature/magic number .version:8 = 'h' for Bzip2 ('H'uffman coding) .hundred_k_blocksize:8 = '1'..'9' block-size 100 kB-900 kB .compressed_magic:48 = 0x314159265359 (BCD (pi)) .crc:32 = checksum for this block ... ... .eos_magic:48 = 0x177245385090 (BCD sqrt(pi)) .crc:32 = checksum for whole stream .padding:0..7 = align to whole byte http://en.wikipedia.org/wiki/Bzip2 So I know where the CRC

CRC32 algorithm/implementation in C without a look up table and with a public license [closed]

天大地大妈咪最大 提交于 2019-12-21 04:27:38
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . I am trying to implement a CRC32 algorithm in C that does not use a look up table (I need to use it in a boot loader that doesn't have enough memory available to have one). Is there an available solution to this that has a public license? 回答1: A quick search harvested this webpage. I wasn't able to find the

How to implement CRC32 taking advantage of Intel specific instructions?

Deadly 提交于 2019-12-20 10:02:10
问题 Intel has a specific CRC32 instruction available in the SSE4.2 instruction set. How can I take advantage of this instruction to speed up CRC32 calculations? 回答1: First of all the Intel's CRC32 instruction serves to calculate CRC-32C (that is uses a different polynomial that regular CRC32. Look at the Wikipedia CRC32 entry) To use Intel's hardware acceleration for CRC32C using gcc you can: Inline assembly language in C code via the asm statement Use intrinsics _mm_crc32_u8 , _mm_crc32_u16 ,

How can i receive the wrong Ethernet frames and disable the CRC/FCS calcul?

人走茶凉 提交于 2019-12-18 13:27:27
问题 I generate a traffic between two PCs running Linux (by sending Ethernet frames), the goal of this is to capture some errors frames. The problem is when the Phy layer detect an error on a frame (if the CRC or FCS is not valid) the frame is dropped and I can't receive it in my program. Are the any way to receive the wrong frame (disable the drops in the Phy layer and receiving a indicator that indicate that this frame is wrong for example) and how can i consult the statistic of the NIC card

Can one construct a “good” hash function using CRC32C as a base?

谁说我不能喝 提交于 2019-12-18 12:46:11
问题 Given that SSE 4.2 (Intel Core i7 & i5 parts) includes a CRC32 instruction, it seems reasonable to investigate whether one could build a faster general-purpose hash function. According to this only 16 bits of a CRC32 are evenly distributed. So what other transformation would one apply to overcome that? Update How about this? Only 16 bits are suitable for a hash value. Fine. If your table is 65535 or less then great. If not, run the CRC value through the Nehalem POPCNT (population count)

php crc32 注意事项

半世苍凉 提交于 2019-12-18 10:13:12
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> crc32返回的结果在32位机上会产生溢出,所以结果可能为负数。而在64位机上不会溢出,所以总是正值。 CRC算法是按字长位数bit进行计算的。 crc32函数会按照php中的两个常量参考计算 PHP_INT_SIZE,PHP_INT_MAX 这两个常量的定义: 整型数的字长和平台有关,尽管通常最大值是大约二十亿(32 位有符号)。PHP 不支持无符号整数。Integer值的字长可以用常量PHP_INT_SIZE来表示,自 PHP 4.4.0 和 PHP 5.0.5后,最大值可以用常量PHP_INT_MAX来表示。 输出下32位中PHP_INT_SIZE:4,PHP_INT_MAX:2147483647 输出下64位中PHP_INT_SIZE:8,PHP_INT_MAX:9223372036854775807 来源: oschina 链接: https://my.oschina.net/u/98890/blog/785420

Compute a CRC32C (Castagnoli) which uses the generator polynomial 1EDC6F41h following Rocksoft Model CRC Algorithm in Python

牧云@^-^@ 提交于 2019-12-13 09:09:12
问题 I did explore Crcmod python library but couldnt use it as my gen poly- 0x1EDC6F41 is not considered a 32 bit poly :( Is there a way to tweak it or any other python lib that I can use to do this? Name : "CRC-32C" Width : 32 Poly : 1EDC6F41h Init : FFFFFFFFh RefIn : True RefOut : True XorOut : FFFFFFFFh Check : E3069283h Here is what I tried- import crcmod f = crcmod.mkCrcFun(0x1EDC6F41) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Python27\Lib\site-packages

CRC32 on integer in Sphinx

三世轮回 提交于 2019-12-13 03:48:17
问题 I am trying to use CRC32 to to randomize results in a Sphinx query which already has several nested orders e.g. Select CRC32(Field) as Random from Index Order by Premium,Weight(),Random However, the only unique field I have is a reference . It is an integer so randomizes via CRC32 as 0 . I selected it in my Sphinx Config Select... reference as Randomizer... and then specified it as a string so I could use it in the select: sql_field_string = Randomizer So it would be 'converted' to text.

Same crc32 for Python and C

半世苍凉 提交于 2019-12-12 09:17:41
问题 I need script that will calculate crc32 with the same output for both Python and C. I'm using right now zlib.crc32, but for C there is no such library and we are writing it on our own basing on Wikipedia. But it doesn't return the same value. This is our code of C script (copied from wikipedia, based on RFC): unsigned int crc32( unsigned char *message, unsigned int n ) { //int i, crc; unsigned int crc; unsigned int i; unsigned int byte, c; const unsigned int g0 = 0xEDB88320, g1 = g0>>1, g2 =