I'm using AIX 4.3.2 with ksh and would like to set up an alphanumeric paging script which is compatible with the New Zealand Telecom TAP protocol, which uses a checksum of the message to verify its accuracy. To achieve this, I would like a script (perferably perl) which performs the following:
1. Take as input, a file which may include printable and "unprintable" characters.
2. Produce as output, a number which is the sum of the ASCII values of all the charaters in the file.
Eg: If the file contains:
This would add up as follows:
So, the output should be 235 (decimal).
If you've done that, here's an optional part for extra points:
1. Take the last 12 bits of the above.
2. Convert each group of 4 bits into the ASCII chars 48 ("0") to 63 ("?").
Eg: In the case of a checksum like 12667 (decimal), this converts to binary:
11 0001 0111 1011
The last 12 bits are:
0001 0111 1011
Or in decimal:
1 7 11
And you can just add 48 (decimal) to each of these to get:
49 55 59
Which can be represented by ASCII chars:
1 7 ;
So the output should be:
I will probably "reject" non-perl answers until I give up waiting for perl answers, since perl is my preference.