Java Utililty Methods Checksum Calculate

List of utility methods to do Checksum Calculate

Description

The list of methods to do Checksum Calculate are organized into topic(s).

Method

bytecalcChecksum(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;
bytecalcChecksum(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;
intcalcCheckSum(byte[] bytes, int num)
calc Check Sum
return calcCheckSum(bytes, 0, bytes.length, num);
intcalcCheckSum(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;
charcalcChecksum(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;
...
StringcalculateChecksum(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 {
...
MapcalculateChecksums(Optional zos, InputStream inputStream, Set checksumAlgorithms)
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 {
...
longcheckSum(boolean[] a)
check Sum
long sum = 0;
for (int j = 0; j < a.length; j++) {
    sum += (a[j] ? j + 1 : 0);
return sum;
intcheckSum(byte abyte0[])
check Sum
int i = 0;
for (int j = 0; j < abyte0.length; j++)
    i += abyte0[j] & 255;
return i;
bytechecksum(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;