得到一个字符串的哈希Hash值

来源:互联网 发布:淘宝店铺售假扣24分 编辑:程序博客网 时间:2024/06/08 17:06
function StrHash(const SoureStr: string): Cardinal;  const    cLongBits = 32;    cOneEight = 4;    cThreeFourths = 24;    cHighBits = $F0000000;  var    I: Integer;    P: PChar;    Temp: Cardinal;  begin    Result := 0;    P := PChar(SoureStr);    I := Length(SoureStr);    while I > 0 do    begin      Result := (Result shl cOneEight) + Ord(P^);      Temp := Result and cHighBits;      if Temp <> 0 then        Result := (Result xor (Temp shr cThreeFourths)) and (not cHighBits);      Dec(I);      Inc(P);    end;  end;end.

0 0