Java tutorial
//package com.java2s; //License from project: Open Source License public class Main { /** * Creates a NMEA checksum for a sentence. * * The checksum is calculated by XOR every char value, between '$' and * '*'(end), with the current sum. * * @param sbString * String to calculate the checksum. * @return The checksum. */ public static int getNMEAChecksum(final StringBuilder sbString) { int checksum = 0; for (int i = 0; i < sbString.length(); i++) { if (sbString.charAt(i) != '*' && sbString.charAt(i) != '$') checksum ^= sbString.charAt(i); } return checksum; } }