computeByteHash method

int computeByteHash(
  1. int byteSize
)

Hashes the bytes until byteSize.

Implementation

int computeByteHash(int byteSize) {
  // 0x811c9dc5 is the 32-bit FNV offset basis
  var hash = 0x811c9dc5;

  // Read bytes from memory address
  for (var i = 0; i < byteSize; i++) {
    // 0x01000193 is the 32-bit FNV prime
    hash = (hash ^ readUint8(i)) * 0x01000193;
    // Force 32-bit unsigned wrap in Dart VM
    hash &= 0xFFFFFFFF;
  }

  return hash;
}