str_checksum.cc 830 B

12345678910111213141516171819202122232425262728293031
  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. #include "string/str_checksum.hh"
  9. w32 i4_str_checksum(const i4_const_str &str)
  10. {
  11. i4_const_str::iterator i=str.begin();
  12. int len=str.length();
  13. w8 c1=0,c2=0,c3=0,c4=0;
  14. while (len)
  15. {
  16. c1+=i.get().value();
  17. c2+=c1;
  18. c3+=c2;
  19. c4+=c3;
  20. ++i;
  21. len--;
  22. }
  23. return (c1|(c2<<8)|(c3<<16)|(c4<<24));
  24. }