mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-07-25 01:59:04 +10:00
fix: Correct return type of _manualAckHash and improve hash computation
This commit is contained in:
@@ -14,7 +14,7 @@ import 'package:meshcore_open/services/message_retry_service.dart';
|
|||||||
|
|
||||||
/// Replicates the SHA-256 computation from [MessageRetryService.computeExpectedAckHash]
|
/// Replicates the SHA-256 computation from [MessageRetryService.computeExpectedAckHash]
|
||||||
/// so tests can cross-check without calling the real implementation twice.
|
/// so tests can cross-check without calling the real implementation twice.
|
||||||
Uint8List _manualAckHash(
|
int _manualAckHash(
|
||||||
int timestampSeconds,
|
int timestampSeconds,
|
||||||
int attemptMasked, // already masked to 0x03
|
int attemptMasked, // already masked to 0x03
|
||||||
String text,
|
String text,
|
||||||
@@ -35,7 +35,8 @@ Uint8List _manualAckHash(
|
|||||||
buffer.setRange(offset, offset + senderPubKey.length, senderPubKey);
|
buffer.setRange(offset, offset + senderPubKey.length, senderPubKey);
|
||||||
|
|
||||||
final hash = sha256.convert(buffer);
|
final hash = sha256.convert(buffer);
|
||||||
return Uint8List.fromList(hash.bytes.sublist(0, 4));
|
final bytes = Uint8List.fromList(hash.bytes.sublist(0, 4));
|
||||||
|
return (bytes[3] << 24) | (bytes[2] << 16) | (bytes[1] << 8) | bytes[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
Uint8List _makeKey(int seed) {
|
Uint8List _makeKey(int seed) {
|
||||||
|
|||||||
Reference in New Issue
Block a user