computeCheckSum function
dynamic
computeCheckSum(
- dynamic bytes
Implementation
function computeCheckSum(bytes) {
while (bytes.length % 4 !== 0) {
bytes.push(0);
}
let sum = 0;
for (let i = 0; i < bytes.length; i += 4) {
sum += (bytes[i] << 24) +
(bytes[i + 1] << 16) +
(bytes[i + 2] << 8) +
(bytes[i + 3]);
}
sum %= Math.pow(2, 32);
return sum;
}