@Override
public Checksum compute(final InputStream in, final TransferStatus status) throws ChecksumException {
final InputStream normalized = this.normalize(in, status);
final CRC32 crc32 = new CRC32();
try {
byte[] buffer = new byte[16384];
int bytesRead;
while((bytesRead = normalized.read(buffer, 0, buffer.length)) != -1) {
crc32.update(buffer, 0, bytesRead);
}
}
catch(IOException e) {
throw new ChecksumException(LocaleFactory.localizedString("Checksum failure", "Error"), e.getMessage(), e);
}
finally {
IOUtils.closeQuietly(normalized);
}
return new Checksum(HashAlgorithm.crc32, Long.toHexString(crc32.getValue()));
}
}