Is it possible to define a CRC zip file?

I'm not sure if I got the concept correctly, but I know that we can check the integrity of files in zip by getting CRC values ​​for each record. However, my question is if I get a zip file, will there be a CRC for it, and if so, how can I determine this?

+4
source share
2 answers

You can use java.util.zip.CRC32 to calculate the CRC-32 checksum for any data stream.

 BufferedInputStream bis = new BufferedInputStream( new FileInputStream(new File("/path/to/file.zip"))); int read = 0; CRC32 checksum = new CRC32(); byte[] buffer = new byte[1024]; while ((read = bis.read(buffer)) != -1) { checksum.update(buffer, 0, read); } bis.close(); System.out.println ("CRC32 of your zip is: " + checksum.getValue()); 
+6
source

You can use the checksumCRC32 method from the FileUtils class in the org.apache.commons.io package.

+3
source

Source: https://habr.com/ru/post/1487389/


All Articles