Operation | 20
Below is a program, written in the ‘C’ programming language that illustrates the checksum calculation.
/*
return the checksum character for the message in array
subtract 32 from each character before taking modulo 95 sum
add 32 to the final sum
mes_len = message length
*/
char check_sum(char *array, char mes_len)
{
char i,sum;
for ( i = 0, sum = 0; i < mes_len; i++ ) {
sum += *array++ - 32;
sum %= 95;
}
return(sum + 32);
}