I want to calculate CRC32 value of a byte array with an initial CRC value in Java, same as in this Python script:
import zlib
def getCrc32():
with open("test.py", mode='rb') as file:
fileContent = file.read()
crcVal = zlib.crc32(fileContent,10)
if __name__ == "__main__":
getCrc32()
But in Java, I can not get the same result with the following code:
RandomAccessFile f = new RandomAccessFile("test.py", "r");
byte[] b = new byte[(int) f.length()];
f.readFully(b);
CRC32 c2 = new CRC32();
c2.update(10);
c2.update(b);
System.out.println((int) c2.getValue());
How can I calculate CRC32 with an inital value in Java ?