B4J Code Snippet CRC32

This might be useful to someone - and perhaps there's a better way??

I knocked this out a while back because I needed to calculate a reliable CRC32. I got the algorithm from somewhere online but I've since lost the link :(

I wrote it as a class (but it can easily be converted to a code module). Just initialize the class and then call Calc() - passing in the byte array. It will return an INT which is the CRC32.

Note: the code is quick when run in Release but in Debug it can run quite slow (depending on the size of the array that the CRC32 is being calculated for)

I should also mention that this works equally as well with B4A - not sure about B4i/R as yet. Maybe someone could comment if it works ok for those two IDEs ;)

:)
 

Attachments

  • CRC32.zip
    688 bytes · Views: 369
Last edited:

techknight

Well-Known Member
Licensed User
Longtime User
Awesome work. Just a heads up that it is not correct, or at least it is not generating the correct values.

Using a custom polynomial, the Int output that I convert to hex is Different than that of Hex Workshop, and Python. Python and Hexworkshop plus other CRC utilities all put out the same value. This one is different therefore its broken.

Why? I dont know. Maybe we can figure it out?
 
Top