Calculating the Checksum of a Byte Array

byte[] bytes = "some data".getBytes(); // Compute Adler-32 checksum Checksum checksumEngine = new Adler32(); checksumEngine.update(bytes, 0, bytes.length); long checksum = checksumEngine.getValue(); // Compute CRC-32 checksum checksumEngine = new CRC32(); checksumEngine.update(bytes, 0, bytes.length); checksum = checksumEngine.getValue(); // The checksum engine can be reused again for a different byte array by calling reset() checksumEngine.reset();

Post a comment

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image. Ignore spaces and be careful about upper and lower case.