IdHashElf.pas 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. {
  2. $Project$
  3. $Workfile$
  4. $Revision$
  5. $DateUTC$
  6. $Id$
  7. This file is part of the Indy (Internet Direct) project, and is offered
  8. under the dual-licensing agreement described on the Indy website.
  9. (http://www.indyproject.org/)
  10. Copyright:
  11. (c) 1993-2005, Chad Z. Hower and the Indy Pit Crew. All rights reserved.
  12. }
  13. {
  14. $Log$
  15. }
  16. {
  17. Rev 1.1 2003-10-16 11:22:42 HHellström
  18. Fixed for dotNET
  19. Rev 1.0 11/13/2002 07:53:32 AM JPMugaas
  20. }
  21. unit IdHashElf;
  22. interface
  23. {$i IdCompilerDefines.inc}
  24. uses
  25. IdGlobal,
  26. IdHash;
  27. type
  28. TIdHashElf = class(TIdHash32)
  29. public
  30. procedure HashStart(var VRunningHash : UInt32); override;
  31. procedure HashByte(var VRunningHash : UInt32; const AByte : Byte); override;
  32. end;
  33. implementation
  34. { TIdHashElf }
  35. procedure TIdHashElf.HashStart(var VRunningHash: UInt32);
  36. begin
  37. VRunningHash := 0;
  38. end;
  39. procedure TIdHashElf.HashByte(var VRunningHash: UInt32; const AByte: Byte);
  40. var
  41. LTemp: UInt32;
  42. begin
  43. VRunningHash := (VRunningHash shl 4) + AByte;
  44. LTemp := VRunningHash and $F0000000;
  45. if LTemp <> 0 then begin
  46. VRunningHash := VRunningHash xor (LTemp shr 24);
  47. end;
  48. VRunningHash := VRunningHash and (not LTemp);
  49. end;
  50. end.