I use java.util.zip.CRC32 which I understand implements CRC32 (and not CRC32b), but it seems like I need to use CRC32b instead of CRC32.
is there a Java open source
CRC32b is a coined term if I remember correctly, equal to CRC32 with the 4 bytes reversed.
int crc32b(int crc) {
ByteBuffer buf = ByteBuffer.allocate(4);
buf.putInt(crc); // BIG_ENDIAN by default.
buf.order(ByteOrder.LITTLE_ENDIAN);
return buf.getInt(0);
}
For instance for input '1':
byte b = (byte) '1';
CRC32 crc = new CRC32();
crc.update(b);
System.out.printf("%x%n", crc.getValue());
int finalCRC = crc32b((int)crc.getValue());
System.out.printf("%x%n", finalCRC);
Output:
83dcefb7
b7efdc83
Given your example the conclusion: java CRC32 (without reversal) is fine.