configurationSignature property

String get configurationSignature

A deterministic signature suitable for generated definition names.

Implementation

String get configurationSignature {
  final offsetBasis = BigInt.parse('cbf29ce484222325', radix: 16);
  final prime = BigInt.parse('100000001b3', radix: 16);
  final mask = BigInt.parse('ffffffffffffffff', radix: 16);
  var hash = offsetBasis;
  for (final sourceIndex in _sourceIndices) {
    var remaining = BigInt.from(sourceIndex);
    do {
      hash ^= remaining & BigInt.from(0xff);
      hash = (hash * prime) & mask;
      remaining >>= 8;
    } while (remaining != BigInt.zero);
    hash ^= BigInt.from(0xff);
    hash = (hash * prime) & mask;
  }
  return hash.toRadixString(16).padLeft(16, '0');
}