Maybe perl's unpack is enough for you:
In addition to fields allowed in pack, you may prefix a field with a <number> to indicate that you want a <number>-bit checksum of the items instead of the items themselves. Default is a 16-bit checksum. The checksum is calculated by summing numeric values of expanded values (for string fields the sum of ord ($char) is taken; for bit fields the sum of zeroes and ones).
For example, the following computes the same number as the System V sum program:
my $checksum = do {
local $/; # slurp!
unpack ("%32W*", readline) % 65535;
};
Enjoy, Have FUN! H.Merijn