digest static method

int digest(
  1. Uint8List key,
  2. int seed, {
  3. int? offset,
  4. int? len,
})

Implementation

static int digest(
  Uint8List key,
  int seed, {
  int? offset,
  int? len,
}) {
  offset = offset ?? 0;
  len = len ?? (key.length - offset);

  final int n = offset + (len & ~3);

  int hash = seed;
  int i = offset;
  for (; i < n; i += 4) {
    final int chunk = Buffers.getUInt32(key, i);
    hash ^= scramble32(chunk);
    hash = rotl32(hash, 13);
    hash = (imul32(hash, 5) + 0xe6546b64) & 0xffffffff;
  }

  switch (len & 3) {
    case 3:
      hash ^= scramble32(Buffers.getUInt24(key, i));
      break;
    case 2:
      hash ^= scramble32(Buffers.getUInt16(key, i));
      break;
    case 1:
      hash ^= scramble32(Buffers.getUInt8(key, i));
      break;
    case 0:
    default:
      break;
  }

  hash ^= len;
  hash = fmix32(hash);
  return hash;
}