public static uint ComputeFileChecksum(byte[] fileBytes) { // caesar uses a 0x8000 block size // const int blockSize = 0x8000; const int blockSize = int.MaxValue; // skip the appended checksum fileBytes = fileBytes.Take(fileBytes.Length - 4).ToArray(); int fileCursor = 0; uint currentChecksum = 0xFFFFFFFF; while (fileCursor < fileBytes.Length) { byte[] blockToRead = fileBytes.Skip(fileCursor).Take(blockSize).ToArray(); fileCursor += blockSize; currentChecksum = CaesarReader.CrcAccumulate(blockToRead, currentChecksum); } return(currentChecksum); }
public static uint ComputeFileChecksumLazy(byte[] fileBytes) { return(CaesarReader.CrcAccumulate(fileBytes, 0xFFFFFFFF, fileBytes.Length - 4)); }