I have been beaten to it it seems (damn it, I wrote it so i'll post it at least), but I have knocked up something quick and dirty (in C) here:
Code:
#include <stdio.h>
#include <sys\file.h>
int main(int argc, char *argv[])
{
int fd ;
int checksum = 0;
char chr[1];
fd = open(argv[1],O_RDONLY); //open file
if (fd == -1)
{
printf("Unable to open file");
}
else
{
while(read(fd,chr,1)==1) //read each char at a time til failure (EOF)
{
checksum += chr[0]; //add ASCII value to cumlative value
}
}
printf("Checksum in decimal: %d\n", checksum); //display total in decimal
printf("Checksum in hex: %X", checksum); //display total in hexadecimal
close(fd);
return 0;
}
And you call it like this (after compile and linking, assuming the output is called checksum, of course)
checksum filename
If you need me to add more comments in it, or explain anything, let me know. It needs a bit more work (check there is a parameter in the command line), but it does the job.
The psuedo-code is more or less the same, which is why it looks so close to Phil's version. Basically:
1. Open a file
2. Read one character at a time until you get a null value/error
3. Add the ascii value (normally cast character to an integer) to a cumlative value
4. format and display the integer as a hexadecimal value.
HTH