Scalabium Software

SMReport Autogenerated

Knowledge for your independence.
Home Delphi and C++Builder tips



#136:ELF hash algorithm

Sometime ago I posted a code for hash calculation of strings (CRC32 and easy method which is extracted from VCL sources). Today I want to post a code for ELF algorithm which allow to receive a strong distributed hash from string. This algorithm is very popular because can be implemented in any programming language (from VB to Java) and is a very-very fast (contain one easy loop only).

See a code below:

function ElfHash(const Value: string): Integer;
var
  i, x: Integer;
begin
  Result := 0;
  for i := 1 to Length(Value) do
  begin
    Result := (Result shl 4) + Ord(Value[i]);
    x := Result and $F0000000;
    if (x <> 0) then
      Result := Result xor (x shr 24);
    Result := Result and (not x);
  end;
end;

A few examples you can see in table below:

Text value

Calculated elf-hash

Scalabium Software 189378421
Scalabium 136833325
scalabium.com 153641565
www.scalabium.com 156665277
See also
 
DBISAM Password Recovery
DBExport tools
Database Information Manager
Excel Reader (dll)
DBISAM Viewer
Protected Storage Viewer
Paradox Password Recovery
Fast Document Viewer
Paradox to Text converter
SMImport suite
 
 
Contact to webmaster

 

Interested in technology and considering going after a job in web programming? It's easy to get an online education in Information Technology, so you can live your aspirations. Locate college grants as well as education grants to enable your success.


Borland Software Code Gear Scalabium Delphi tips

Copyrightc 1998-2009, Scalabium Software. All rights reserved.
webmaster@scalabium.com

December 13, 2001

SMExport advertising