aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/helper/Checksum.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar/helper/Checksum.java')
-rw-r--r--src/org/traccar/helper/Checksum.java9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/org/traccar/helper/Checksum.java b/src/org/traccar/helper/Checksum.java
index 2a4b1191d..dde174545 100644
--- a/src/org/traccar/helper/Checksum.java
+++ b/src/org/traccar/helper/Checksum.java
@@ -194,6 +194,15 @@ public final class Checksum {
return checksum;
}
+ public static int xor(String string) {
+ byte[] bytes = string.getBytes(StandardCharsets.US_ASCII);
+ byte sum = 0;
+ for (byte b : bytes) {
+ sum ^= b;
+ }
+ return sum;
+ }
+
public static String nmea(String msg) {
int checksum = 0;
for (byte b : msg.getBytes(StandardCharsets.US_ASCII)) {