crc32

CRC32 C or C++ implementation [closed]

我们两清 提交于 2019-11-27 11:38:49
I'm looking for an implementation of CRC32 in C or C++ that is explicitly licensed as being no cost or public domain. The implementation here seems nice, but the only thing it says about the license is "source code", which isn't good enough. I'd prefer non LGPL so I don't have to fool around with a DLL (my app is closed source). I saw the adler32 implementation in zlib, but I'm checking small chunks of data, which adler is not good for. Zan Lynx Use the Boost C++ libraries . There is a CRC included there and the license is good. The SNIPPETS C Source Code Archive has a CRC32 implementation

Can CRC32 be used as a hash function?

别等时光非礼了梦想. 提交于 2019-11-27 10:19:29
问题 Can CRC32 be used as a hash function? Any drawbacks to this approach? Any tradedeoffs? 回答1: CRC32 works very well as a hash algorithm. The whole point of a CRC is to hash a stream of bytes with as few collisions as possible. That said, there are a few points to consider: CRC's are not secure. For secure hashing you need a much more computationally expensive algorithm. For a simple bucket hasher, security is usually a non-issue. Different CRC flavors exist with different properties. Make sure

Why does BCL GZipStream (with StreamReader) not reliably detect Data Errors with CRC32?

半城伤御伤魂 提交于 2019-11-27 08:45:45
The the other day I ran into the question GZipStream doesn't detect corrupt data (even CRC32 passes)? (Of which this might very well be a "duplicate", I have mixed feelings on the subject. I was also the one who added the CRC32 to the title, but in retrospect that feels out of place with the remainder of the post). After exploring the problem a bit on my own, I think that the issue is far greater than the other question initially portrays. I expanded upon the other question and made the test code runnable under LINQPad and attempt to better showcase the CRC32 (Cyclic Redundancy Check) issue,

Python CRC-32 woes

你说的曾经没有我的故事 提交于 2019-11-27 06:18:01
问题 I'm writing a Python program to extract data from the middle of a 6 GB bz2 file. A bzip2 file is made up of independently decryptable blocks of data, so I only need to find a block (they are delimited by magic bits), then create a temporary one-block bzip2 file from it in memory, and finally pass that to the bz2.decompress function. Easy, no? The bzip2 format has a crc32 checksum for the file at the end. No problem, binascii.crc32 to the rescue. But wait. The data to be checksummed does not

Reversing CRC32

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-27 01:38:42
I'm looking for a way to reverse a CRC32 checksum . There are solutions around, but they are either badly written , extremely technical and/or in Assembly . Assembly is (currently) beyond my ken, so I'm hoping someone can piece together an implementation in a higher level language. Ruby is ideal, but I can parse PHP, Python, C, Java, etc. Any takers? A CRC32 is only reversible if the original string is 4 bytes or less. Read the document called "Reversing CRC Theory and Practice" . This is C#: public class Crc32 { public const uint poly = 0xedb88320; public const uint startxor = 0xffffffff;

How do I calculate CRC32 of a string

浪子不回头ぞ 提交于 2019-11-26 23:03:01
How do I calculate the CRC32 (Cyclic Redundancy Checksum) of a string in .NET? Pete This guy seems to have your answer. https://damieng.com/blog/2006/08/08/calculating_crc32_in_c_and_net And in case the blog ever goes away or breaks the url, here's the github link: https://github.com/damieng/DamienGKit/blob/master/CSharp/DamienG.Library/Security/Cryptography/Crc32.cs Usage of the Crc32 class from the blog post: Crc32 crc32 = new Crc32(); String hash = String.Empty; using (FileStream fs = File.Open("c:\\myfile.txt", FileMode.Open)) foreach (byte b in crc32.ComputeHash(fs)) hash += b.ToString(

JavaScript CRC32

时光总嘲笑我的痴心妄想 提交于 2019-11-26 18:55:22
问题 I'm looking for a modern JavaScript implementation of CRC32. This implementation, which may have originated from here, and is now here, there and everywhere, is unacceptable because it's slow (500ms/MB), and depends on over 2KB of space delimited table, accessed using substr. Yuck! There appears to be a few variations of CRC32, so I need to match this output: mysql> SELECT CRC32('abcde'); > 2240272485 Function doesn't actually need to accept a string however, since I'm working with byte

How is a CRC32 checksum calculated?

随声附和 提交于 2019-11-26 18:49:47
问题 Maybe I'm just not seeing it, but CRC32 seems either needlessly complicated, or insufficiently explained anywhere I could find on the web. I understand that it is the remainder from a non-carry-based arithmetic division of the message value, divided by the (generator) polynomial, but the actual implementation of it escapes me. I've read A Painless Guide To CRC Error Detection Algorithms, and I must say it was not painless. It goes over the theory rather well, but the author never gets to a

Implementing SSE 4.2's CRC32C in software

你。 提交于 2019-11-26 18:42:16
So I have a design which incorporates CRC32C checksums to ensure data hasn't been damaged. I decided to use CRC32C because I can have both a software version and a hardware-accelerated version if the computer the software runs on supports SSE 4.2 I'm going by Intel's developer manual (vol 2A), which seems to provide the algorithm behind the crc32 instruction. However, I'm having little luck. Intel's developer guide says the following: BIT_REFLECT32: DEST[31-0] = SRC[0-31] MOD2: Remainder from Polynomial division modulus 2 TEMP1[31-0] <- BIT_REFLECT(SRC[31-0]) TEMP2[31-0] <- BIT_REFLECT(DEST[31

Why does BCL GZipStream (with StreamReader) not reliably detect Data Errors with CRC32?

十年热恋 提交于 2019-11-26 17:46:32
问题 The the other day I ran into the question GZipStream doesn't detect corrupt data (even CRC32 passes)? (Of which this might very well be a "duplicate", I have mixed feelings on the subject. I was also the one who added the CRC32 to the title, but in retrospect that feels out of place with the remainder of the post). After exploring the problem a bit on my own, I think that the issue is far greater than the other question initially portrays. I expanded upon the other question and made the test