source: golgotha/src/i4/string/str_checksum.cc

Last change on this file was 80, checked in by Sam Hocevar, 15 years ago
  • Adding the Golgotha source code. Not sure what's going to be interesting in there, but since it's all public domain, there's certainly stuff to pick up.
File size: 830 bytes
Line 
1/********************************************************************** <BR>
2  This file is part of Crack dot Com's free source code release of
3  Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
4  information about compiling & licensing issues visit this URL</a>
5  <PRE> If that doesn't help, contact Jonathan Clark at
6  golgotha_source@usa.net (Subject should have "GOLG" in it)
7***********************************************************************/
8
9#include "string/str_checksum.hh"
10
11w32 i4_str_checksum(const i4_const_str &str)
12{
13  i4_const_str::iterator i=str.begin();
14
15  int len=str.length();
16 
17  w8 c1=0,c2=0,c3=0,c4=0;
18
19  while (len)
20  {
21    c1+=i.get().value();
22    c2+=c1;
23    c3+=c2;
24    c4+=c3;
25    ++i;
26    len--;
27  }
28
29  return (c1|(c2<<8)|(c3<<16)|(c4<<24));
30}
Note: See TracBrowser for help on using the repository browser.