fingerprint static method
Implementation
static Future<String> fingerprint(UDocByteSource source) async {
final int head = source.length < uDocBlockSize ? source.length : uDocBlockSize;
final Uint8List first = await source.read(0, head);
final int tailOffset = source.length > head ? source.length - head : 0;
final Uint8List last = tailOffset == 0 ? Uint8List(0) : await source.read(tailOffset, head);
int low = 0x811c9dc5;
int high = 0xdeadbeef;
void mix(int byte) {
low = _fnv32(low, byte);
high = _jenkins32(high, byte);
}
for (final int byte in first) {
mix(byte);
}
for (final int byte in last) {
mix(byte);
}
mix(source.length & 0xFF);
mix((source.length >> 8) & 0xFF);
mix((source.length >> 16) & 0xFF);
mix((source.length >> 24) & 0xFF);
final String highHex = _jenkins32Finish(high).toRadixString(16).padLeft(8, "0");
final String lowHex = low.toRadixString(16).padLeft(8, "0");
return "${source.length.toRadixString(16)}-$highHex$lowHex";
}