trajectoryContentHash function

String trajectoryContentHash(
  1. String text
)

Stable content hash of text: two independent 32-bit FNV-1a lanes (different basis/primes) over the UTF-8 bytes, hex-encoded as 16 characters. Not a security primitive — a dedup key for blob tables. Two lanes instead of one 64-bit hash because 64-bit literals cannot be represented exactly under dart2js (web builds).

Implementation

String trajectoryContentHash(String text) {
  var hi = 0x811c9dc5;
  var lo = 0x811c9dc5;
  for (final byte in utf8.encode(text)) {
    hi = ((hi ^ byte) * 0x01000193) & 0xFFFFFFFF;
    lo = ((lo ^ byte) * 0x01935619) & 0xFFFFFFFF;
  }
  return hi.toRadixString(16).padLeft(8, '0') +
      lo.toRadixString(16).padLeft(8, '0');
}