Archived

This topic is now archived and is closed to further replies.

davidko

CRC32 implementations

Recommended Posts

I''m looking for an equivalent implementation of the CRC32 as that which is found in java.util.zip.CRC32. I wanted to implemented this in C++ so that both algorithms come out with the same numbers. Unfortunately, all the implementations I''ve tested come out with inconsistent results. Does anyone know where I can find the same implementation that java uses? A temporary solution I''m using is to just LoadLibrary the zip.dll library that java uses for its implementation. But I''d prefer to have my own implementation in C++. Thanks

Share this post


Link to post
Share on other sites

Hmm... if you used the same CRC-32 algorithm, the calculated
result should be the same. All CRC-32 is, is a polynomial in
modulo mathematics. Maybe you made a mistake in your C++
function?

Different implementation may be using different coefficients,
so the answers are different. Why don''t you just get the
source code to zlib and use zlib''s CRC-32?

I''d recommend against writing your own "zlib". Your time is better spent on writing your application. Really. Do you
think you can write a better "zlib"?


Premature optimizations can only slow down your project even more.

Share this post


Link to post
Share on other sites
he may just need the crc32 portion and not the entire compression package. which in that case its silly to include the entire zlib library.

question, why do you need the same numbers as java.util.zip.CRC32?

btw the magic number for zip files is 0xdebb20e3 which is probably the same thing java.util.zip.CRC32 uses.

Share this post


Link to post
Share on other sites
tangentz, i am not familar with the liscense of zlib, but wouldn''t copy the code require you to GPL your code as well or is it BSD? cause you dont want him breaking the liscence, which would further bring down the open source community. if they dont want the code used in closed source productions, and you dont want your code open, then its best not to use open source libraries.

Share this post


Link to post
Share on other sites
quote:
Original post by a person
tangentz, i am not familar with the liscense of zlib, but wouldn''t copy the code require you to GPL your code as well or is it BSD?

ZLib is under the ZLib license (go figure). It''s probably the most open license I''ve seen (basically self protection for the author''s and nothing more).

Share this post


Link to post
Share on other sites

Whoa, hold on, when did I say anything about breaking licenses?

Please don''t put words into my mouth.

So what if you have to GPL your code? The original poster
didn''t say anything about that.

You sound like you support the open source community, no?
So what''s better than to get more code open source? I
don''t understand what you''re ranting about.

To answer the relevant question, if you read zlib''s license,
it''s pretty much "use at your own risk" type. No GPL or
nothing. You just need to give credits to zlib''s authors,
that''s all.


Premature optimizations can only slow down your project even more.

Share this post


Link to post
Share on other sites
sorry if i sounded harsh. i just was trying to make him aware about using other ppls code, so he dont become one of those bad coders that steal from the open source community disreagarding the liscense. now that i re read it , the words are probally put together wrong and sound more directed at you then i had intended.

Share this post


Link to post
Share on other sites