aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/helper/Checksum.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/traccar/helper/Checksum.java')
-rw-r--r--src/main/java/org/traccar/helper/Checksum.java8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/main/java/org/traccar/helper/Checksum.java b/src/main/java/org/traccar/helper/Checksum.java
index adfa697c5..d41dc2992 100644
--- a/src/main/java/org/traccar/helper/Checksum.java
+++ b/src/main/java/org/traccar/helper/Checksum.java
@@ -168,6 +168,14 @@ public final class Checksum {
return checksum;
}
+ public static int modulo256(ByteBuffer buf) {
+ int checksum = 0;
+ while (buf.hasRemaining()) {
+ checksum = (checksum + buf.get()) & 0xFF;
+ }
+ return checksum;
+ }
+
public static String sum(String msg) {
byte checksum = 0;
for (byte b : msg.getBytes(StandardCharsets.US_ASCII)) {