Kod
function StrToStrHash(Str, Key: String): String;
var
i: Integer;
begin
Result := '';
for i := 1 to length(Key) do
Result := Result + IntToBaseX(StrToHash(Str, i * ord(Key[i])), 62);
end;{StrToStrHash}
function StrToHash(Str: String; Method: Cardinal): Cardinal;
const
Pow: array[0..7] of Integer = (1, 2, 4, 8, 16, 32, 64, 128);
var
i, j, ByteVal: Integer;
TestBit: Boolean;
begin
Result := 0;
for i := 1 to length(Str) do
begin
ByteVal := ord(Str[i]);
for j := 7 downto 0 do
begin
TestBit := ((Result and 32768) = 32768) xor ((ByteVal and Pow[j]) = Pow[j]);
Result := ((Result and 32767) * 2);
if TestBit then Result := Result xor Method;
end;{for j}
end;{for i}
end;{StrToHash}
var
i: Integer;
begin
Result := '';
for i := 1 to length(Key) do
Result := Result + IntToBaseX(StrToHash(Str, i * ord(Key[i])), 62);
end;{StrToStrHash}
function StrToHash(Str: String; Method: Cardinal): Cardinal;
const
Pow: array[0..7] of Integer = (1, 2, 4, 8, 16, 32, 64, 128);
var
i, j, ByteVal: Integer;
TestBit: Boolean;
begin
Result := 0;
for i := 1 to length(Str) do
begin
ByteVal := ord(Str[i]);
for j := 7 downto 0 do
begin
TestBit := ((Result and 32768) = 32768) xor ((ByteVal and Pow[j]) = Pow[j]);
Result := ((Result and 32767) * 2);
if TestBit then Result := Result xor Method;
end;{for j}
end;{for i}
end;{StrToHash}