aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/helper
diff options
context:
space:
mode:
authorVitaly Litvak <vitavaque@gmail.com>2016-10-02 08:17:43 +0300
committerVitaly Litvak <vitavaque@gmail.com>2016-10-02 08:17:43 +0300
commit9cc1cbd2b21afcd40091069d2f0a58565db18c15 (patch)
tree5393357116c24bc217a604e31e4a5fe1730b41c7 /src/org/traccar/helper
parentb5a09475b90b044cf0b5b0f64d8709dd7e92c460 (diff)
downloadtrackermap-server-9cc1cbd2b21afcd40091069d2f0a58565db18c15.tar.gz
trackermap-server-9cc1cbd2b21afcd40091069d2f0a58565db18c15.tar.bz2
trackermap-server-9cc1cbd2b21afcd40091069d2f0a58565db18c15.zip
Moved 'xor' checksum method to the utility class.
Diffstat (limited to 'src/org/traccar/helper')
-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)) {