How do I calculate the checksum of a byte array?
Created May 4, 2012
John Zukowski The Adler32 class in the java.util.zip package can be used to calculate the sum:
byte buffer[] = ... ByteArrayInputStream bais = new ByteArrayInputStream(buffer); CheckedInputStream cis = new CheckedInputStream(bais, new Adler32()); byte readBuffer[] = new byte[128]; while (cis.read(readBuffer) >= 0); long value = cis.getChecksum().getValue();