Files
SpotiFLAC-Mobile/lib/utils/hash_utils.dart
T
zarzet adf2047df6 refactor(utils): share the FNV-1a 32-bit hash
Add fnv1a32 in hash_utils.dart for the scan output name (UTF-8 bytes) and
qualityVariantStagingLabel (UTF-16 code units). Unit tests pin outputs
computed from the original inline code.
2026-10-19 00:15:48 +07:00

12 lines
325 B
Dart

/// FNV-1a 32-bit hash over [units] (UTF-8 bytes or UTF-16 code units).
///
/// The result feeds on-disk file names, so the algorithm must not change.
int fnv1a32(Iterable<int> units) {
var hash = 0x811c9dc5;
for (final unit in units) {
hash ^= unit;
hash = (hash * 0x01000193) & 0xffffffff;
}
return hash;
}