mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-10-21 06:52:18 +02:00
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.
12 lines
325 B
Dart
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;
|
|
}
|