Java CRC32 calculate checksum

Description

Java CRC32 calculate checksum

import java.util.zip.CRC32;

public class Main {
  public static void main(String[] args) throws Exception {
    String str = "demo2s.com";
    byte[] data = str.getBytes("UTF-8");

    // Compute CRC32 checksum
    CRC32 crc = new CRC32();
    crc.update(data);/* www . j  a v a2  s.  c  o m*/
    long crc32Checksum = crc.getValue();
    System.out.println("CRC32: " + crc32Checksum);


  }
}



PreviousNext

Related