Article View: borland.public.cppbuilder.internet.socket
Article #2314Re: TIdHashMessageDigest5 and BCB 6
From: Remy Lebeau (TeamB)
Date: Tue, 27 Jun 2006 17:35
Date: Tue, 27 Jun 2006 17:35
68 lines
2692 bytes
2692 bytes
"Lapo Guidi" <lapoguidi@inwind.it> wrote in message
news:44a15dd2@newsgroups.borland.com...
> This is the T4x4LongWordRecord declaration:
> T4x4LongWordRecord = array [0..3] of LongWord;
In C++, it comes out as the following:
typedef unsigned T4x4LongWordRecord[4];
The declaration for T4x4x4LongWordRecord in C++ comes out as follows:
typedef unsigned T4x4x4LongWordRecord[4][4];
Functions in C++ can't return array values. However, if you look at the
declaration for HashValue() itself in C++, it does not return an array at
all:
unsigned __fastcall HashValue(const AnsiString ASrc);
What you can try doing is to add a Delphi .pas file to your C++ project, and
have that file call HashValue() and return the array in a manner that C++
can handle. For example (untested):
--- HashValueUnit.pas ---
unit HashValueUnit;
uses
IdHashMessageDigest5;
interface
procedure MD5HashValue(MD5: TIdHashMessageDigest5; const S: String; var
Hash: PLongWord);
implementation
procedure MD5HashValue(MD5: TIdHashMessageDigest5; const S: String;
Hash: PLongWord);
var
Tmp: T4x4LongWordRecord;
begin
Tmp := MD5.HashValue(S);
Move(Tmp[0], Hash, SizeOf(LongWord)*4);
end;
end.
--- MyForm.cpp ---
#include "HashValueUnit.hpp"
{
//...
TIdHashMessageDigest5 *MD5 = new TIdHashMessageDigest5;
T4x4LongWordRecord Hash;
MD5HashValue(MD5, "testmessage", Hash);
AnsiString Hex = MD5->AsHex(__classid(TIdHashMessageDigest5), Hash);
//...
}
Gambit
Technical Details
Message-ID:
<44a16cdf$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<44a11d2e@newsgroups.borland.com> <44a12658$1@newsgroups.borland.com> <44a12cf6@newsgroups.borland.com> <44a13849@newsgroups.borland.com> <44a15dd2@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,c6188de51aacc8b4 X-Google-Attributes: gid11508e,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> Newsgroups: borland.public.cppbuilder.internet.socket References: <44a11d2e@newsgroups.borland.com> <44a12658$1@newsgroups.borland.com> <44a12cf6@newsgroups.borland.com> <44a13849@newsgroups.borland.com> <44a15dd2@newsgroups.borland.com> Subject: Re: TIdHashMessageDigest5 and BCB 6 Date: Tue, 27 Jun 2006 10:35:09 -0700 Lines: 70 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 NNTP-Posting-Host: 68.69.17.41 Message-ID: <44a16cdf$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1151429855 68.69.17.41 (27 Jun 2006 10:37:35 -0700) Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail