Java CRC32C calculate check sum

Description

Java CRC32C calculate check sum

import java.util.zip.CRC32C;
import java.util.zip.Checksum;

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

    // Compute CRC32C checksum
    Checksum crc32c = new CRC32C();
    crc32c.update(data);//from  w ww  . j  a v  a2s.c  o  m
    long crc32cChecksum = crc32c.getValue();
    System.out.println("CRC32C: " + crc32cChecksum);
  }
}



PreviousNext

Related