generateBytesHashCode static method

int generateBytesHashCode(
  1. List<int> bytes, [
  2. List<Object> optional = const []
])

Generates a hash code for a list of bytes, optionally including additional objects in the calculation.

Returns: A 32-bit integer hash code.

Implementation

static int generateBytesHashCode(List<int> bytes,
    [List<Object> optional = const []]) {
  int hash = 12;
  for (final element in bytes) {
    hash ^= element;
    hash = (hash * 31) & mask32;
  }
  if (optional.isNotEmpty) {
    hash = (hash ^ generateHashCode(optional)) & mask32;
  }
  return hash;
}