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
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Ross Levis
> Sent: Wednesday, 12 November 2003 9:08 p.m.
> To: Multiple recipients of list delphi
> Subject: Re: [DUG]: Copy protection/program registration
>
>
> I've managed to get an ASP page working, thanks to Stephen.
> Though I had to change the C:\ to Server.MapPath(). And
> CreateTextFile seems to only have 2 parameters. What does
> the 3rd one do?
>
> I would like to convert a small delphi hash function to
> VBScript but I've never used VB or VBScript before. Can
> anyone help with this, or is it even possible?
>
> function Hash(const Buf: String): LongInt;
> var
> I, X: LongInt;
> begin
> Result := 0;
> for I := 1 to Length(Buf) do
> begin
> Hash := (Result shl 4) + Byte(Buf[I]);
> X := Result and $F0000000;
> if (X <> 0) then Result := Result xor (X shr 24);
> Result := Result and (not X);
> end;
> end;
>
> Feeding in "ABC" results in the number 17763.
>
> Many thanks,
> Ross Levis.
>
> --------------------------------------------------------------
> -------------
> 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/
>
---------------------------------------------------------------------------
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/