Hi L505,

Here is my actual implementation (and working great) of the
function... in case you would like to update your example. Thanks all
for the help. (I'm still opened to any improvements: toward the
perfect code ;). )

{ Summary:
    Create a MD5 hash from a string and return the result.
  Arguments:
    ASource = source string from which we calculate the md5
    ADestination = destination string to which we save the hexadecimal
      representation of the md5 (always 32+1 in size)
    ADestinationMaxSize = size of the allocated ADestination string; it should
      be at least (32+1) or the function will fail.
  Note:
    The ADestinationMaxSize is technicaly useless, but it is introduced as an
    example of a typical library working with strings.
  Results:
    MD5 result will be saved in ADestination. Returns the size of the md5 hash
    if succesfull or -1 if failed write the hash in ADestination. }

function MakeMD5Hash(ASource: PChar; ADestination: PChar;
ADestinationMaxSize: LongInt): LongInt; stdcall;
var
  s: string;
  sSize: LongInt;
begin
  s := MD5Print(MD5String(ASource));
  sSize := Length(s) + 1;

  if sSize <= ADestinationMaxSize then
  begin
    Move(PChar(s)^, ADestination^, sSize);
    Result := sSize;
  end else
    Result := -1;
end;


On 12/30/05, L505 <[EMAIL PROTECTED]> wrote:
> I have made an example for md5 hash
> http://z505.com/cgi-bin/qkcont/qkcont.cgi?p=MD5Hash-Example
>
> _________________________________________________________________
>      To unsubscribe: mail [EMAIL PROTECTED] with
>                 "unsubscribe" as the Subject
>    archives at http://www.lazarus.freepascal.org/mailarchives
>


--
Alexandre Leclerc

_________________________________________________________________
     To unsubscribe: mail [EMAIL PROTECTED] with
                "unsubscribe" as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives

Reply via email to