Android Question Simple checksum?

Chris Lee

Member
Licensed User
Hi all,

Just wondering if anyone has a code example of generating simple checksums?

Let's say I have a set of numbers:

1,2,2,2,1,1,2,2,1,1

I need a simple algorithm that can generate a checksum. The ordering of items is important and should produce a different checksum if the same set of numbers are in a different order.

To give an idea of scale, I will have maybe 50 rows of 10 numbers each row will need to have a checksum generated.

I don't have much experience in this area, but I'm wondering if any existing libraries do this or if anyone has a routine that already does something similar?

Any suggestions would be very much appreciated.
 

JordiCP

Well-Known Member
Licensed User
Longtime User
There are several CRC implementations. For instance


It expects an array of bytes as an input, so you'll need to adapt each row to an array of bytes directly if your numbers are already dimmed as bytes, or 'transform' them to bytes with byteconverter if this is not the case.
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
I suggest to use MD5 or SHA to encode the values as 1 string.
 
Upvote 0
Top