Hi Wes

It did need some alteration.  Mid$ = Mid.  There are no type definations
like Long or String.  But it now works.  Thank you very much.  I would have
had much trouble with the shl.

Regards,
Ross Levis.

----- Original Message ----- 
From: "Wes Edwards" <[EMAIL PROTECTED]>
To: "Multiple recipients of list delphi" <[EMAIL PROTECTED]>
Sent: Wednesday, November 12, 2003 9:42 PM
Subject: RE: [DUG]: Hash function in VB (was Copy protection/program
registration)


> Hi Ross,
>
> This is the function implemented in VBA so hopefully this isn't too far
> off - it returns the correct result for "ABC"
>
> Public Function Hash(Buf As String) As Long
>   Dim I As Long
>   Dim X As Long
>   Dim Result As Long
>
>   Result = 0                        '  Result := 0;
>   For I = 1 To Len(Buf)             '  for I := 1 to Length(Buf) do
>     Result = (Result * 2 ^ 4) + Asc(Mid$(Buf, I, 1))   '    Hash :=
> (Result shl 4) + Byte(Buf[I]);
>     X = Result And &HF0000000       '    X := Result and $F0000000;
>     If (X <> 0) Then
>       Result = Result Xor (X \ 2 ^ 24) '    if (X <> 0) then Result :=
> Result xor (X shr 24);
>     End If
>     Result = Result And (Not X)        '    Result := Result and (not
> X);
>   Next I
>   Hash = Result
> End Function
>
> Wes

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/

Reply via email to