B4J Code Snippet CRC32

Discussion in 'B4J Code Snippets' started by Ed Brown, Nov 8, 2017.

  1. Ed Brown

    Ed Brown Active Member Licensed User

    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 ;)

    :)
     

    Attached Files:

    Last edited: Nov 8, 2017
  2. techknight

    techknight Well-Known Member Licensed 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?
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice