List of utility methods to do Checksum Calculate
byte | calcChecksum(byte[] buffer, int offset, int length) Returns the checksum for the specified bytes. byte crc = 0x7F; for (int i = 0; i < length; i++) { crc = (byte) ((crc - buffer[offset + i]) & 0x7F); return crc; |
byte | calcChecksum(byte[] buffer, int start, int end) calc Checksum byte c = 0; for (int i = start + 2, num = end - 1; i < num; ++i) c ^= buffer[i]; return c; |
int | calcCheckSum(byte[] bytes, int num) calc Check Sum return calcCheckSum(bytes, 0, bytes.length, num);
|
int | calcCheckSum(byte[] data, int offset, int maxIdx) checksum is across the body from start of tag 35 to the delimiter at end of tag before checksum int val = 0; for (int idx = offset; idx < maxIdx;) { val += data[idx++]; val = val & 0xFF; return val; |
char | calcChecksum(String value, int length) calc Checksum if (value != null && value.length() == length + 1) { value = value.substring(0, length); if (value == null || value.length() != length) { throw new IllegalArgumentException( "Illegal size of value; must be either" + length + " or " + (length + 1) + " characters"); int oddsum = 0; ... |
String | calculateChecksum(InputStream is, String algorithm) Calculates checksum, closing the inputstream in the end. MessageDigest digester = MessageDigest.getInstance(algorithm); try { byte[] block = new byte[4096]; int length; while ((length = is.read(block)) > 0) { digester.update(block, 0, length); } finally { ... |
Map | calculateChecksums(Optional calculate Checksums byte[] buffer = new byte[4096]; Map<String, String> values = new HashMap<>(); Map<String, MessageDigest> algorithms = new HashMap<>(); for (String alg : checksumAlgorithms) { algorithms.put(alg, MessageDigest.getInstance(alg)); int numRead; do { ... |
long | checkSum(boolean[] a) check Sum long sum = 0; for (int j = 0; j < a.length; j++) { sum += (a[j] ? j + 1 : 0); return sum; |
int | checkSum(byte abyte0[]) check Sum int i = 0; for (int j = 0; j < abyte0.length; j++) i += abyte0[j] & 255; return i; |
byte | checksum(byte current, final byte[] data, final int offset, final int length) Computes a STM32 checksum. for (int i = offset; i < offset + length; i++) current ^= data[i] & 0xFF; return (byte) current; |