seedFromUuid static method

BigInt seedFromUuid(
  1. String uuid
)

The seed for a UUID string: its last 48 bits (the last 12 hex digits), as the native SDKs use.

An invalid UUID falls back to seed 0, whose hash is 0, so it is sampled for any rate above 0 (fail-open).

Implementation

static BigInt seedFromUuid(String uuid) {
  final hex = uuid.replaceAll('-', '');
  final seed = hex.length >= 12
      ? int.tryParse(hex.substring(hex.length - 12), radix: 16) ?? 0
      : 0;
  return BigInt.from(seed);
}