diff options
Diffstat (limited to 'src/org/traccar/helper/Checksum.java')
-rw-r--r-- | src/org/traccar/helper/Checksum.java | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/org/traccar/helper/Checksum.java b/src/org/traccar/helper/Checksum.java index 5aed84bf8..adfa697c5 100644 --- a/src/org/traccar/helper/Checksum.java +++ b/src/org/traccar/helper/Checksum.java @@ -160,6 +160,14 @@ public final class Checksum { return String.format("*%02x", checksum).toUpperCase(); } + public static int sum(ByteBuffer buf) { + byte checksum = 0; + while (buf.hasRemaining()) { + checksum += buf.get(); + } + return checksum; + } + public static String sum(String msg) { byte checksum = 0; for (byte b : msg.getBytes(StandardCharsets.US_ASCII)) { |