Just out of curiosity this really, I found this checksum algorithm by a bit of reverse engineering of some old network code, it was being used to check UDP datagrams. I wondered if some of the more experienced coders here might recognise it as a standard algorithm, or whether it's proprietory?
Code:
u16 GetChecksum(BYTE data[], u16 datalength){
unsigned int bytesum=0;
unsigned int cumulativebytesum=0;
for(int i = datalength; i>0; i--){
bytesum+=data[i-1];
if(bytesum>0xFF) bytesum-=0xFF;
cumulativebytesum+=bytesum;
}
BYTE remainder = cumulativebytesum%0xFF;
remainder = (remainder+bytesum)%0xFF;
BYTE byte1 = 0xFF-remainder;
BYTE byte2 = 0xFF-(byte1+bytesum)%0xFF;
return 0x100*byte1+byte2;
}