mirror of
https://github.com/dz0ny/meshcore-sar.git
synced 2026-08-11 16:30:28 +00:00
fix: Replace web unsafe hash
ref:
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
import 'package:crypto/crypto.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:geolocator/geolocator.dart';
|
import 'package:geolocator/geolocator.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
@@ -1006,15 +1007,12 @@ class _LiveTrafficPacketDetails {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static String _packetHash(List<int> bytes) {
|
static String _packetHash(List<int> bytes) {
|
||||||
const fnvOffset = 0xcbf29ce484222325;
|
final digest = md5.convert(bytes).bytes;
|
||||||
const fnvPrime = 0x100000001b3;
|
return digest
|
||||||
const mask = 0xFFFFFFFFFFFFFFFF;
|
.take(8)
|
||||||
var hash = fnvOffset;
|
.map((byte) => byte.toRadixString(16).padLeft(2, '0'))
|
||||||
for (final byte in bytes) {
|
.join()
|
||||||
hash ^= byte & 0xFF;
|
.toUpperCase();
|
||||||
hash = (hash * fnvPrime) & mask;
|
|
||||||
}
|
|
||||||
return hash.toRadixString(16).padLeft(16, '0').toUpperCase();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user